I have 10 viewControllers in my application. I clicked all these viewControllers using the pushViewController method for the NavigationController, by pressing the NEXT button of each viewController click.
I used the code for this:
[self.navigationController pushViewController:someView animated:YES];
Now I want to return to rootViewController from the 10th child (viewController).
How can i do this?
Please help me..
Thank.
try to use.
[self.navigationController popToRootViewControllerAnimated:YES];
Use this code:
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:NO];//Use the desired index instead of 1 here
[self.navigationController popViewControllerAnimated:YES]
[self.navigationController popViewControllerAnimated:YES] .
NSInteger index = 0; for (UIViewController *view in self.navigationController.viewControllers) { if([view.nibName isEqualToString:@"RootViewController"])//put any `XIB name` where u want to navigate break; index = index + 1; } [[self navigationController] popToViewController:[[self.navigationController viewControllers] objectAtIndex:index] animated:YES];
To return to the previous screen (the last element of the view controller stack), click the view controller:
[self.navigationController popViewControllerAnimated:YES];