下面是两个SwiftUI视图的示例,它们具有关闭窗口而不是关闭DetailView的意外行为:
struct ContentView: View {
var body: some View {
NavigationView {
NavigationLink(destination: DetailView()) {
Text("Go to detail view")
}
}
}
}
struct DetailView: View {
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
var body: some View {
Button(action: { presentationMode.wrappedValue.dismiss() }) {
Text("Dismiss")
}
}
}
1条答案
按热度按时间jexiocij1#
您还可以使用NavigationSplitView来通知您NavigationView现在已弃用