Post

Replies

Boosts

Views

Activity

navigationDestination(isPresent:content) in NavigationStack doesn't work on iOS16.1 beta
Hi, I've just finished replacing to NavigationStack, but I'm having trouble with this issue. The following simple sample code works on iOS 16.0 production, but it doesn't work on iOS 16.1 beta. When navigationDestination(isPresent:) is called, Xcode displays runtime warning message, but I cannot understand what the means. A `navigationDestination(isPresented:content:)` is outside an explicit NavigationStack, but inside the detail column of a NavigationSplitView, so it attempts to target the next column. There is no next column after the detail column. Did you mean to put the navigationDestination inside a NavigationStack? I didn't use NavigationSplitView and navigationDestination(isPresent:) is inside NavigationStack. Could someone please point out the problem with this code? Or is it a SwiftUI bug? Test environment Xcode Version 14.1 beta 2 (14B5024i) iPhone SE (3rd gen) (iOS 16.1) Sample Code @main struct StackViewSampleApp: App {     var body: some Scene {         WindowGroup {             NavigationStack {                 ContentView()             }         }     } } struct ContentView: View {     var body: some View {         List {             NavigationLink("SubView1") {                 SubView1()             }             NavigationLink("SubView2") {                 SubView2()             }         }     } } struct SubView1: View {        @State private var isPresent: Bool = false      var body: some View {         Button("A") {             isPresent = true         }         .navigationDestination(isPresented: $isPresent) {             Text("TEST")         }     } } struct SubView2: View {     enum ViewType {         case a, b, c     }     @State private var selection: ViewType? = nil     let viewTypes: [ViewType] = [.a, .b, .c]     var body: some View {         List(selection: $selection) {             ForEach(viewTypes, id: \.self) { t in                 NavigationLink(value: t) {                     Text("\(String(describing: t))")                 }             }         }         .navigationDestination(isPresented: .init(get: {             selection != nil         }, set: { newValue in             if !newValue {                 selection = nil             }         })) {             Text("\(String(describing: selection))")         }     } }
3
0
1.7k
Sep ’22