leonnib4
leonnib4

Reputation: 3

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

Upvotes: 0

Views: 1266

Answers (1)

Nick Lockwood
Nick Lockwood

Reputation: 41005

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

Upvotes: 2

Related Questions