Remove Stacked views from NavigationView in SwiftUI

Hi, I am using NavigationLink on SwiftUI to navigate from one view to another. My problem is that i can not find a way to access the stacked Views on NavLink and go back to previous view programmatically, skipping the views in between. For example View A -> View B -> ViewC -> View D -> press back ---> View B (I need to remove ViewC from the NavView stack so on back i should go to viewB again.)

I am using NavigationLink(destination: , tag: , selection: ) { } constructor on the entire application.

Is there any way to access and manage the stacked views in NavigationLink?

Thank you.

Answered by Claude31 in 693994022

Here it describe how to go back to the root view:

https://stackoverflow.com/questions/57334455/swiftui-how-to-pop-to-root-view

It is easily adaptable to return to another view in stack.

Accepted Answer

Here it describe how to go back to the root view:

https://stackoverflow.com/questions/57334455/swiftui-how-to-pop-to-root-view

It is easily adaptable to return to another view in stack.

Remove Stacked views from NavigationView in SwiftUI
 
 
Q