我有一个Actionsheet,我不知道如何从"动作表"回调按钮中导航到另一个视图。
let action = ActionSheet.Button.cancel {
//navigation???
}
ActionSheet(title: Text("some title"), buttons: [action])
即:在选择不同来源的图像时,我想将其作为选择:
这就是您的实现方式:
struct ContentView: View {
@State var isSheet: Bool = false
@State var isPresented: Bool = false
var body: some View {
NavigationView {
Button(dict.description) {
self.isSheet = true
}.actionSheet(isPresented: $isSheet) {
ActionSheet(title: Text("Some title"), message: nil, buttons: [
.default(Text("Present view")) {
self.isPresented = true
},
.cancel()
])
}
.navigationBarTitle(Text("Home"))
.sheet(isPresented: $isPresented, content: { Text("This is another view!") })
}
}
}
而不是.sheet
,您也可以使用.popover