NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

Pop multiple views off a navigation stack

Forums > SwiftUI

I have a tabbed view where one of the tabs takes the user through a number of "Add Item" screens, which are part of a Navigation Stack. The general workflow is as follows:

Tab - Add Item Home -> Add Item selected -> Enter item name (Screen #1) -> Next -> Enter Item details (Screen #2) -> Next -> Enter Item details (Screen #3) -> Done

When the user selects Done I would like to pop all of teh views off the navigation stack and return to the 'Add Item Home' screen. I know I can use

 @Environment(\.presentationMode) var mode: Binding<PresentationMode>

combined with


to dismiss one screen (the equivalent of pressing back) but how do I pop all views from Navigation stack?


I too, wonder if there's a way to go about doing this without just rendering a view programmatically.

Right now, I just have an if/else in my code that wraps the whole thing...

if (self.showHomeView) {
} else {
  // Some other view that is nested deeply in my app but when this page is done I want to go back to the home view
  VStack {
    Text("Hello world")


Just found this stack overflow and the first answer seems to be a good one


Hacking with Swift is sponsored by Essential Developer

SPONSORED From January 26th to 31st you can join a FREE crash course for iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a senior developer!

Save your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.