- (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 - |
Pergunta
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.
Solução 2
Outras dicas
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)#>];
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow