I’m creating a universal iOS app that is essentially one long order page. The user starts on a shopping cart screen, and then they progress linearly (using UINavigationController) through a series of 4 different screens (different VC). Once they reach the last screen the press submit and I want the app to then take the user back to the shopping cart screen. However, the shopping cart screen is NOT the root view controller thus I cannot use [self.navigationController popToRootViewControllerAnimated:YES];. How should I accomplish this? How do people usually accomplish this?
A few ideas that I’ve though of are:
1) Maintain a global variable that is the VC I want to pop to? For instance, whenever the user went to the shopping cart page I’d set the shopping cart VC to be value of this global variable.
2) Once I’m on the last page, loop through the stack of VCs on the navigation controller stack and then when I find one of the type that I want (same class) I’d pop to it.
Is there a better way to do this? Is there some magical API that I’m missing? What do people do in circumstances like these?
Use:
That is, find your shopping cart object and use that as the viewController argument.