- (IBAction)GoFirstView:(id)sender
{
for (UIViewController *controller in self.navigationController.viewControllers)
{
if ([controller isKindOfClass:[Firstviewcontroller class]])
{
//Do not forget to import Firstviewcontroller.h
[self.navigationController popToViewController:controller animated:YES];
break;
}
}
}
How to pop thirdviewcontroller to firstviewcontroller in singleview app
-
21-07-2023 - |
Question
In my app
I have three uiviewcontroller
: firstviewcontroller, secondviewcontroller and thirdviewcontroller.
I go from firstviewcontroller to secondviewcontroller using navigationcontroller and then from secondviewcontroller to thirdviewcontroller
I want go back from thirdviewcontroller to fristviewcontroller.
Solution 2
OTHER TIPS
use below code:
[self.navigationController popToRootViewControllerAnimated:YES];
also for moving to any particular viewController which is in navigation hierarchy you can use below code:
[self.navigationController popToViewController:<#(UIViewController *)#> animated:<#(BOOL)#>];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow