Reputation: 35953
I have this app that will have a single flow, something like a wizard, basically composed of 4 view controllers. Lets call them A, B, C and D.
Application starts showing A. From A, the user can go to B. From B the user can go to C or back to B. From D the user can go back to C or finish doing something and go back to A.
Something like:
A <-> B <-> C <-> D
^ |
┕━━━━━━━━━━━━━━━━━┙
My point is this:
If I start on A, present B, present C, present D, all these A, B and C will be on the stack, so I can pop and go back to the last one, but when I am in D, in my head, the correct way to go to A, would be to pop D, C and B from the stack. How can I go from D to A, getting rid of everything that is on the stack?
thanks.
Upvotes: 0
Views: 78
Reputation: 33428
An UINavigationController
could be a valid solution. By means of this component you have this type of linear workflow for free.
See Apple's documentation. UINavigationController Class Reference
Upvotes: 1
Reputation: 48398
This line may be what you're after:
[self.navigationController popToRootViewControllerAnimated:YES];
Apple's UINavigationController Class Reference has excellent illustrations and examples for doing more exotic things (like jumping from D to B).
Upvotes: 1
Reputation: 22395
You can use UINavigationControllers popToRootViewControllerAnimated:
, here is a reference UINavigationController Class Ref
Upvotes: 1