NavigationStack 2: Programmable NavigationPath and DeepLinks
Why Stack Overflow recommends it
Stack Overflow users link it when working out how to programmatically control iOS 16 NavigationStack paths, including pop-to-root behavior and router-style navigation.
Recommended by 1 people across 1 different months, 2022 to 2024.
What it is
A 28-minute SwiftUI tutorial by Stewart Lynch, the second in his iOS 16 navigation series. It shows how to drive a NavigationStack with a programmable NavigationPath, build a back-to-root button using a global router object, and handle deep links through a custom URL scheme.
What people said
Recommends Gordon · 2024-05 · Stack Overflow · on “SwiftUI Error: Update NavigationAuthority bound path tried to update multiple times per frame”
@kuhlemann can you point me to some more detail on this, appropriate for a total beginner? I have been learning from Stewart Lynch's year old info on programable links in NavigationStacks ( [this video] ) which uses an `@ObservableObject` Router class and `@EnvironmentObject` variables in the views, and I am not finding anything about refactoring that for an `@State` based approach.
Cites Mgwd · 2022-09 · Stack Overflow · on “Why doesn't clearing the new iOS 16 SwiftUI NavigationPath to "pop to root" animate smoothly back to the root view?”
I have a new iOS 16 SwiftUI NavigationStack with navigation determined by the NavigationDestination modifier which works fine. My question is why doesn't it animate smoothly by sliding back to the root view when clearing the NavigationPath if you are more than one view deep within the stack? It works if you are only one level deep, but anything lower than that causes "popping to root" to just jump back to the root view without the sliding animation. Is this a "feature" or bug or am I doing something incorrectly? Steps to re-create the issue Run the sample code below. Click the first navigation link and then click "Pop To Root View" - notice that it "slides smoothly" back to root view. Click
Cites Mgwd · 2022-09 · Stack Overflow · on “Why doesn't clearing the new iOS 16 SwiftUI NavigationPath to "pop to root" animate smoothly back to the root view?”
I think this issue must be a feature as I have just seen a YouTube video that exhibits the same functionality - [this video] - around time line 19:25 - you will see pop to root just jumps back to start.
Cites Dan · 2022-11 · Stack Overflow · on “SwiftUI iOS 16 NavigationPath inside TabView Warning: NavigationAuthority”
Hey @malhal I have put them in an ObservableObject so I can push/pop/dismiss from the correct Path depending on the selected tab. These tutorials lead me to this approach... [LINK] , [this video]