简体   繁体   中英

UINavigationController to UIViewController difficulty

How to convert this for UIViewController is it possible:

for (UIViewController *tmpController  in [self.navigationController viewControllers]) 
{
    if ([tmpController isKindOfClass:[RootViewController class]])
    {
        [self.navigationController popToViewController:tmpController animated:YES];
        break;
    }
}

[self.navigationController viewControllers] --> how to convert this for UIViewController , because I'm having error,

[self.navigationController popToViewController:tmpController animated:YES]; --> while this part i convert it to this --> [self dismissModalViewControllerAnimated:YES];

If you have ViewController A that presented ViewController B that Presented ViewController C

And you want to go back to A, do the following, in viewController C

[self dismissModalViewControllerAnimated:NO];
[[self presentingViewController] dismissModalViewControllerAnimated:NO];

您可以按如下方式获取视图层次结构:

for(UIView *view in [self.view subviews])

From the Comments above I feel like you are presenting controllers like From A to B and Than B to C.

Now you want to do from C to A to do that use following code

[self.navigationController popToRootViewControllerAnimated:YES];

EDIT

//Try this.
[[[self parentViewController] parentViewController] dismissModalViewControllerAnimated:YES];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM