NavigationView 和工作表有问题。我有以下流程: - ContentView:有打开 ContentView2 工作表的按钮 - ContentView2:有 NavigationLink,标题转到 ContentView3 - ContentView3:有 NavigationLink,没有标题,将用户定向到 ContentView2
但是,当我设置上述流程时,当用户在 ContentView2 和 ContentView3 之间来回切换时,我最终会得到堆叠的标题。当用户在两个视图之间来回切换时,我将如何防止这种情况并且只有 1 个标题?谢谢!
struct ContentView: View {
@State var showSheet = false
var body: some View {
Button("Click"){
self.showSheet.toggle()
}
.sheet(isPresented: $showSheet) {
ContentView2()
}
}
}
struct ContentView2: View {
var body: some View {
NavigationView {
NavigationLink(destination: ContentView3()){
Text("Click Here")
}
.navigationBarTitle("Bar Title", displayMode: .inline)
}
}
}
struct ContentView3: View {
var body: some View {
NavigationLink(destination: ContentView2()){
Text("Click Here")
}
}
}