Rafael Nascimento Rafael Nascimento - 1 year ago 154
Swift Question

Dismiss Multiple Pushed View Controllers

I'm developing an app where the user can buy some food on the app and get delivered at home.
At some point the user's got some products on his cart (displayed in a tab view controller) and he goes to confirm his address and payment method (these are made in two different pushed view controllers). And when the purchase is done, the app displays some message informing if the payment was successful or not (also displayed in a pushed view controller after he confirms the ).
So, after the user complete the purchase I want to dismiss all those view controllers from the purchase process and go back to the tab view controller by tap on a button.

How do I dismiss all those pushed view controllers?

Here is a image of the storyboard:

enter image description here

Answer Source

You can use the navigation controller's built in functionality to pop back to the root view controller.


This will remove all of the pushed view controllers you have on the navigation stack and return to the base controller on the stack. You can attach this functionality to the action selector for when a button is pressed.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download