Вопрос

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.

Это было полезно?

Решение 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;
        }
    }
}

Другие советы

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)#>];
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top