我得到了一个ActionSheet在iPhone设备上显示得很好。但它对iPad来说是崩溃的。说它需要弹射器的位置。有谁对这个密码有发现吗?我使用的是iOS 13 beta 3和Xcode 11 beta 3。(这使用了在beta 2中不可用的ActionSheet版本)。
import SwiftUI
struct ContentView : View {
@State var showSheet = false
var body: some View {
VStack {
Button(action: {
self.showSheet.toggle()
}) {
Text("Show")
}
.presentation($showSheet) { () -> ActionSheet in
ActionSheet(title: Text("Hello"))
}
}
}
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif发布于 2020-02-06 19:38:33
最后,正如在iOS 13.4中测试的那样,这个问题已经解决了,至少在测试版中是这样的。冲突的约束警告仍然存在,但崩溃已经消失。现在,这是提出行动单的适当方式。
import SwiftUI
struct ContentView : View {
@State var showSheet = false
var body: some View {
VStack {
Button(action: {
self.showSheet.toggle()
}) {
Text("Show")
}
.actionSheet(isPresented: $showSheet, content: { ActionSheet(title: Text("Hello"))
})
}
}
}
struct ContentView_Previews : PreviewProvider {
static var previews: some View {
ContentView()
}
}https://stackoverflow.com/questions/56910941
复制相似问题