简体   繁体   English

iOS - 在父UINavigationController中弹出一个视图

[英]iOS - pop a view in the parent UINavigationController

Here is how my current iPhone app is made: 以下是我目前的iPhone应用程序的制作方法:

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. 我唯一的问题是在UINavigationControllerC的视图中我在我的自定义导航栏中放置了一个UIBarButton,它应该链接到viewA3 ,但是我失败了。

I know I can't do this: 我知道我不能这样做:

[self.navigationController popToRootViewControllerAnimated:YES];

Because UINavigationControllerC != UINavigationControllerA. 因为UINavigationControllerC!= UINavigationControllerA。

  1. Is there a way to get the parent UINavigationController? 有没有办法获得父UINavigationController?

  2. Is there a trick I could use to save UINavigationControllerA inside of UINavigationControllerC? 有没有可以用来在UINavigationControllerC中保存UINavigationControllerA的技巧?

Thx in advance Thx提前

Access self.tabBarController.navigationController instead of self.navigationController ? 访问self.tabBarController.navigationController而不是self.navigationController

This may not work however as Apple explicitly state that putting a UITabBarController inside a UINavigationController is not supported. 但这可能不起作用,因为Apple明确声明不支持在UINavigationController中放置UITabBarController

Another option would be to access the root navigation controller from your appdelegate using something like: 另一个选择是使用以下内容从appdelegate访问根导航控制器:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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