Ios – How to pop two views at once from a navigation controller

iosiphoneuinavigationcontroller

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?

Best Answer

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];
    }
}