Do it:
[[self navigationController] dismissModalViewControllerAnimated:YES];
This will bring you back to the VC that the navigation controller introduced. After that, everything further depends on how you moved these "multiple views" in front of the navigation controller.
Change is an explanation to get to the deepest root ...
It appears that these “multiple views” are on another, underlying the navigation controller stack. This may seem a bit complicated, because a clean way to get back on this stack is to get this base navigation controller to its own root. But how can he know that a modal VC is made over him?
Let me call the view controller, which made a modal representation of the second navigation controller VC_a. This is a fashionably presented navigation controller whose top VC is VC_b. How does VC_a know how to pat the root of the navigation to it when VC_b modally fires itself?
The good answer (usually) is that VC_b decided to reject itself for some reason - some condition in your application / model has changed to make it solve.
We want VC_a to also detect this condition. When VC_b quits and VC_a receives a viewWillAppear message because it needs to be expanded:
// VC_a.m - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; if (/* some app condition that true when VC_b is done */) { // I must be appearing because VC_b is done, and I'm being uncovered // That means I'm done, too. So pop... [self.navigationController popToRootViewControllerAnimated:NO]; } else { // I must be appearing for the normal reason, because I was just pushed onto the stack } }
source share