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:
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.