使用以下代码,在长按时重新排序列表有效,但仅在 iPad 上,在 iPhone 上长按不起作用。我怎样才能让它也能在 iPhone 上运行?
var body: some View {
NavigationView {
List {
ForEach(objects, id: \.firstName) { object in
Text("\(object.firstName) \(object.lastName)")
}
.onMove(perform: move)
}
}
}
func move(from source: IndexSet, to destination: Int) {
objects.move(fromOffsets: source, toOffset: destination)
}