Swiftui 向上移动列表项会导致动画中断

Swiftui 向上移动列表项会导致动画中断,swiftui,swiftui-list,Swiftui,Swiftui List,我只是尝试使用一些非常基本的代码来移动列表中的项目&一切都很好,除非我尝试将一个项目移动到它上面一个位置 看起来好像它首先交换了这两行的数据,然后启动动画将行从原始位置移动 有没有人知道是什么原因导致了这一问题,更重要的是,如何解决这一问题?谢谢 struct ContentView : View { @State var zahlen = [1,2,3,4,5] var body: some View { List { ForEach

我只是尝试使用一些非常基本的代码来移动列表中的项目&一切都很好,除非我尝试将一个项目移动到它上面一个位置

看起来好像它首先交换了这两行的数据,然后启动动画将行从原始位置移动

有没有人知道是什么原因导致了这一问题,更重要的是,如何解决这一问题?谢谢

struct ContentView : View {

    @State var zahlen = [1,2,3,4,5]

    var body: some View {
        List {
            ForEach(zahlen, id: \.self) { z in
                Text("\(z)")
            }.onMove(perform: self.move)
        }.environment(\.editMode, .constant(.active))
    }

    func move(source: IndexSet, destination: Int) {
        zahlen.move(fromOffsets: source, toOffset: destination)
    }
}

这对我来说是一个很快的错误

 struct ContentView : View {

@State var zahlen = [1,2,3,4,5]

var body: some View {
    List {
        ForEach(zahlen, id: \.self.hashValue) //<<-- here it is "hashValue is deprecated as a Hashable requirement." but until the bug is fixed i think we can use it. 
                                             { z in
            Text("\(z)")
        }.onMove(perform: self.move)
    }.environment(\.editMode, .constant(.active))
}

func move(source: IndexSet, destination: Int) {
    zahlen.move(fromOffsets: source, toOffset: destination)
}
struct ContentView:View{
@状态变量zahlen=[1,2,3,4,5]
var body:一些观点{
名单{

ForEach(zahlen,id:\.self.hashValue)/对我来说这是一个快速的bug

 struct ContentView : View {

@State var zahlen = [1,2,3,4,5]

var body: some View {
    List {
        ForEach(zahlen, id: \.self.hashValue) //<<-- here it is "hashValue is deprecated as a Hashable requirement." but until the bug is fixed i think we can use it. 
                                             { z in
            Text("\(z)")
        }.onMove(perform: self.move)
    }.environment(\.editMode, .constant(.active))
}

func move(source: IndexSet, destination: Int) {
    zahlen.move(fromOffsets: source, toOffset: destination)
}
struct ContentView:View{
@状态变量zahlen=[1,2,3,4,5]
var body:一些观点{
名单{

ForEach(zahlen,id:\.self.hashValue)//对于我使用iOS 14.2,这个错误似乎不再发生。

对于我使用iOS 14.2,这个错误似乎不再发生。

我也面临着同样的问题,目前我认为这是一个
SwiftUI
错误,但我很高兴知道解决方案或解决方法。我也面临着同样的问题,目前我认为这是一个问题一个
SwiftUI
错误,但很乐意知道解决方案或解决方法