我有以下 SwiftUI 视图:
struct ContentView: View {
@State var model: Model
var body: some View {
ScrollView {
LazyVGrid(columns: columns, spacing: 10) {
ForEach(model.events, id: \.self) { event in
CardView(event: event)
}
.onMove { indices, newOffset in
model.events.move(fromOffsets: indices, toOffset: newOffset)
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,似乎没有onMove执行闭包。我相信这是因为所有的手势都只给了ScrollView,所以内在的观点不会接受手势。
我尝试将此视图转换为 a List,但是我不想要行分隔符,我认为在 iOS 14 中无法隐藏。
所以,我想知道我需要改变什么才能让它允许用户拖放CardViews 来重新排序它们。谢谢!