James Hu
James Hu

Reputation: 842

UINavigationController inside a UITabBarController inside a UINavigationController

My problem is that I want to have a tab bar view with its children view controllers shown first. In the children view controllers, depending on what controls are clicked, I either want to A) drill down within the tab bar view (swiping away the child view controller) or B) drill down over the tab bar view (swiping away the tab bar view controller).

I've tried solving this problem by wrapping a navigation controller within the children view controllers (so I can drill down using method A) of the tab bar controller and then wrapping another navigation controller around the tab bar controller itself (so I can drill down using method B), hence the title. So it goes: Window -> UINavigationController -> UITabBarController -> UINavigationController -> child view controller

The problem is that I end up with two navigation bars:

two navigation bars!! http://img527.imageshack.us/img527/240/problemc.png

Has anyone else had this problem, and if so, how did you get around it? Thanks!

Upvotes: 1

Views: 1751

Answers (3)

Tiron
Tiron

Reputation: 11

Just hide the bar you don't want, easy as this:

[navigationController setNavigationBarHidden:YES animated:NO];

Upvotes: 1

Alex Reynolds
Alex Reynolds

Reputation: 96927

In this case, perhaps you can simply use a UITabBar and programmatically manage its state, without nesting a tab bar controller inside another controller.

Upvotes: 2

Kevlar
Kevlar

Reputation: 8924

If you're using two nested UINavigationControllers I don't think you can work around having two nav bars. You may be able to subclass or method swizzle UINavigationController for the controller whose bar you don't want to show, and somehow prevent it from appearing or being created. You can probably also set the navigation bar's opaque property or hidden property accordingly which may also work, but you would probably need to do some fancy UIView rearranging to prevent empty gaps.

This is purely speculation; i don't know if either approach would work or how they would, but those ideas are what i would get started with were i trying to do this.

Upvotes: 1

Related Questions