0
struct First_View: View {
    @State var secondViewShown = false
    
    var body: some View {
        NavigationStack {
            VStack {
                Text("Step 1")
                Button(action: { secondViewShown.toggle() }) {
                    Text("Next")
                }
            }
            .navigationDestination(isPresented: $secondViewShown) {
                Second_View().navigationBarHidden(true)
            }
        }
    }
}


struct Second_View: View {
    @State var thirdViewShown = false
    
    var body: some View {
        NavigationStack {
            VStack {
                Text("Step 2")
                Button(action: { thirdViewShown.toggle() }) {
                   Text("Next")
                }
            }
            .navigationDestination(isPresented: $thirdViewShown) {
                Third_View().navigationBarHidden(true)
            }
        }
    }
}

struct Third_View: View {
    var body: some View {
        NavigationStack {
            VStack {
                Text("Step 3")
            }
        }
    }
}

The code above is meant to be 3 pages where on click of a button in each view, the next one appears in a sliding transition from the right. When a user is navigated to the Second_View, thats exactly what happens and works fine.

But, when going from the second to the third view, there's no transition. The Third_View just appears on the screen. I'm guessing it replaced the Second_View instead of adding another destination from the Second_View.

Happy to hear any suggestions!

aali
  • 1
  • 2
  • 2
    Don't use multiple `NavigationStack` like you do, one in the first view is enough. There are many tutorials and info on how to use `NavigationStack`, for example, here: https://developer.apple.com/documentation/swiftui/navigationstack/ also: https://www.hackingwithswift.com/quick-start/swiftui/how-to-use-programmatic-navigation-in-swiftui and if you are familiar with `NavigationView` this: https://developer.apple.com/documentation/swiftui/migrating-to-new-navigation-types – workingdog support Ukraine May 09 '23 at 06:33
  • I didnt use nav view as I believe its getting deprecated but thanks! Your tip regarding Nav Stack fixed it. – aali May 09 '23 at 06:58

0 Answers0