Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 929
Adam Waite Avatar asked Nov 23 '11 03:11

Adam Waite


People also ask

How do I pop two viewControllers at a time?

There's also a setViewControllers(_:animated:) to include the pop animation. Alternatively you could find the second last view controller in the viewControllers array and then use popToViewController to avoid overwriting the entire view controller stack.


1 Answers

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];     } } 
like image 65
Meet Avatar answered Oct 07 '22 00:10

Meet