关于 iOS 15、Xcode 13;我想知道这是一个错误,没有正确实施,还是计划中的非功能特性......
使用具有.swipeActions
调用.confirmationDialog
确认对话框的列表不显示。
参见示例:
import SwiftUI
struct ContentView: View {
@State private var confirmDelete = false
var body: some View {
NavigationView {
List{
ForEach(1..<10) {_ in
Cell()
}
.swipeActions(edge: .trailing) {
Button(role: .destructive) {
confirmDelete.toggle()
} label: {
Label("Delete", systemImage: "trash")
}
.confirmationDialog("Remove this?", isPresented: $confirmDelete) {
Button(role: .destructive) {
print("Removed!")
} label: {
Text("Yes, Remove this")
}
}
}
}
}
}
}
struct Cell: View {
var body: some View {
Text("Hello")
.padding()
}
}