简体   繁体   中英

iOS - pop a view in the parent UINavigationController

Here is how my current iPhone app is made:

UINavigationControllerA [viewA1 viewA2 viewA3]
viewA3 leads to UITabBarControllerB [viewB1 viewB2]
viewB2 leads to UINavigationControllerC [viewC1 viewC2]

I use custom navigation bars and everything is working greate.

My only problem is that in the views of UINavigationControllerC I placed a UIBarButton in my custom navigation bar that should link to viewA3 , but I fail.

I know I can't do this:

[self.navigationController popToRootViewControllerAnimated:YES];

Because UINavigationControllerC != UINavigationControllerA.

  1. Is there a way to get the parent UINavigationController?

  2. Is there a trick I could use to save UINavigationControllerA inside of UINavigationControllerC?

Thx in advance

Access self.tabBarController.navigationController instead of self.navigationController ?

This may not work however as Apple explicitly state that putting a UITabBarController inside a UINavigationController is not supported.

Another option would be to access the root navigation controller from your appdelegate using something like:

((MyAppDelegate *)[UIApplication sharedApplication].delegate).yourNavigationController

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