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.

Was it helpful?

Solution 2

- (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;
        }
    }
}

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
scroll top