Adam Waite Adam Waite - 1 year ago 105
iOS Question

How do I pop two views at once from a navigation controller?

I want to pop to the third view on the navigation stack back to the first view.

I know how to pop one view at once:

[self.navigationController popViewControllerAnimated:YES];

But how do I do two at once?


Answer Source

You can try this to Jump between the navigation controller stack as well

NSMutableArray *allViewControllers = [NSMutableArray arrayWithArray:[self.navigationController viewControllers]];
for (UIViewController *aViewController in allViewControllers) {
    if ([aViewController isKindOfClass:[RequiredViewController class]]) {
        [self.navigationController popToViewController:aViewController animated:NO];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download