如何导航出ActionSheet我只能通过 aText但不能通过 a 的地方NavigationLink?
示例代码:
struct DemoActionSheetNavi: View {
@State private var showingSheet = false
var body: some View {
NavigationView {
Text("Test")
.actionSheet(isPresented: $showingSheet) {
ActionSheet(
title: Text("What do you want to do?"),
message: Text("There's only one choice..."),
buttons: [
.default(Text("How to navigate from here to HelpView???")),
])
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 我需要在ActionSheet. 假设我有一系列选项["Option1", "Option2"],我该如何实现?
.actionSheet(isPresented: self.$showSheet, content: {
ActionSheet(title: Text("Select an option"), buttons: [
.default(Text("Option1")){self.option = 1},
.default(Text("Option2")){self.option = 2},
.default(Text("Option3")){self.option = 3},
.default(Text("Option4")){self.option = 4},
.cancel()])
}
Run Code Online (Sandbox Code Playgroud)