【发布时间】:2020-03-20 11:25:46
【问题描述】:
我正在尝试将 actionSheet 插入到 .tabItem 中的操作按钮中。我只看到一个带有文本“测试 1”的视图。不能让它显示具有不同选项的菜单吗?提前致谢。
@State var showActionSheet = false
...
var actionSheet : ActionSheet{
ActionSheet(title: Text("Crear"), message: Text("Selecciona opción"), buttons: [
.default(Text("Opción 1")),
.default(Text("Opción 2")),
.destructive(Text("Cancel"))
])
}
...
}.tag(1)
Text("Test 1")
.tabItem {
VStack {
Image(systemName: "1.circle")
Button(action: {
self.showActionSheet.toggle()
}) {
Text("Display Action Sheet")
}
.actionSheet(isPresented: $showActionSheet, content: {
self.actionSheet })
}
【问题讨论】:
-
这是不可能的。 TabItem 只需要一个 Image 和一个 Text,它的唯一功能就是切换视图。
标签: swiftui tabitem actionsheet