I have 3 Views, let say view1, view2 and view3.
view1 is home screen.
Now, I am presenting view2 with naviagationView.
Now, on some event, I have pushed view 3 from view2.
So in short, scene is view1(home) -> presented NavigationView(view2) -> pushed view3
Now, from view3, I want to dismiss navigation view and wanted to come back to view1(home).
If I am taking presentationMode environment variable and make call as presentationMode.wrappedValue.dismiss, then it is popping up to view2, but I wanted to dismiss the whole navigationview.
Here, I have just pushed one view. But there are chances that I might have pushed 7-8 views and wanted to dismiss the full navigation view from there.
Is there any way to do this in swiftUI?
NavigationViewis so limited to use. For your case, init another NavigationView, so the whole stack will be replaced. No way to dismiss to root view. Since iOS 16, there's NavigationStack, you can drop support iOS 16 priors and take advantage of that new API.NavigationView. My app has support for iOS 14+.