Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

popviewcontroller for previous two pages

Tags:

iphone

Popviewcontroller in navigationcontroller pops out just current page and sends us to previous page. Is there a way to pop out two pages and go back to page prior to previous one(2 pages back) or i have to push it to that page. thanks

like image 506
pankaj Avatar asked Nov 29 '22 17:11

pankaj


1 Answers

Use this method on UINavigationController:

- (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated

Like this:

NSInteger currentIndex = [self.navigationController.viewControllers indexOfObject:self];
if( currentIndex-2 >= 0 ) {
    [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:currentIndex-2] animated:YES];
}
like image 173
aegzorz Avatar answered Dec 24 '22 10:12

aegzorz