Why does the button "Show second view" not work here?
struct ContentView: View {
@State private var showSecondView = false
var body: some View {
NavigationSplitView {
// Sidebar content irrelevant
} detail: {
if showSecondView {
Text("Success!!").navigationTitle("Second View")
} else {
NavigationStack {
NavigationLink("Subview") {
Button("Show second view") {
showSecondView = true
}.navigationTitle("Subview of First View")
}.navigationTitle("First View")
}
}
}
}
}
When I remove NavigationStack
it still does not work. When I remove NavigationSplitView
or NavigationLink("Subview")
it works. I am compiling for macOS 13.3.1 (a) with Xcode 14.3.