Reputation: 19418
I am having confusion about push navigation controller and pop navigation controller. for example :
I have 5 view controller A , B ,C ,D ,E . I reach to E controller by push navigation from A. Now, after some task I need to navigate directly to the C controller. I know I can do this by using below method .
[self.navigationController popToViewController: animated:];
But I want to know that what about D controller ? will it be in stack or remove from stack ? If D would be in stack then how to remove it from the stack ?
Upvotes: 0
Views: 99
Reputation: 2999
When you call the method
popToViewController:C animated:YES
All the views till C are popped.
its like calling popViewControllerAnimated: 2 times (When you are at E).
If you want to follow the progress you can put some NSLog's in the viewDidUnload/Dealloc(no ARC).
Upvotes: 3
Reputation: 3494
use this
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2] animated:YES]
viewControllers is an array that holds the views that are in the navigation controller sow if you want to reach the C view whitc is nr 2 in the stack just use the above command , Using this command the rest of the views below C will be removed from the stack
Upvotes: 1
Reputation: 9346
If you did not push controller D onto the stack, it's not on the stack.
If you did push controller D onto the stack, and you pop to a controller before it, it will be popped also, and thus not be on the stack anymore. If that wouldn't be the case, using an UINavigationController would be kind of pointless.
Upvotes: 1