ActionSheet
在iPad 上使用 SwiftUIList
时,它会出现在错误的位置,特别是如果列表的样式设置为GroupedListStyle
.
使用此代码:
struct ContentView: View {
@State var presentAction: Bool = false
var body: some View {
NavigationView {
List {
Section {
Button(action: {
self.presentAction.toggle()
}) {
Text("Present")
}
.actionSheet(isPresented: $presentAction) {
ActionSheet(title: Text("This is an action sheet"), buttons: [
.destructive(Text("Destroy all"))
])
}
}
}.listStyle(GroupedListStyle())
}
.navigationViewStyle(StackNavigationViewStyle())
}
}
结果如下图所示(iPad Pro 10.5"):
但在我当前的应用程序中,情况更糟: