1

I want to push a view from the UITabBarControler. My app hierarchy looks like this:

UINavigationController -> UIView -> UITabBarController

I have a UITabBarController with 3 tabs. On the first tab, I have added a UITableView. How can I make it so that the selection of a cell in the table pushes to another view without navigating from the tab control?

John Topley
  • 113,588
  • 46
  • 195
  • 237
Mihin
  • 320
  • 1
  • 15

3 Answers3

3

Your problem is the arrange you are doing.

You are using UINavigationController -> UIView -> UITabBarController, so UITabBarController is a subview of the UINavigationController. When you navigate, the view you are popping is FROM THE NAVIGATION CONTROLLER, so ALL its content (including the UITabBarController) will disappear.

You structure needs to be like this:

UITabBarController -> UINavigationController -> UIView, which means one UINavigationController per every tab that needs it.

For example, if you need to use push inside two tabs, the structure should be like this:

UITabBarController

|  --> UINavigationController 1 --> UIView 1 --> (push segue) --> UIView 1B

|  --> UINavigationController 2 --> UIView 2 --> (push segue) --> UIView 2B
user1981275
  • 13,002
  • 8
  • 72
  • 101
Alejandro Iván
  • 3,969
  • 1
  • 21
  • 30
1

If you really want a navigation-controller type push inside the tab bar interface, you need a navigation interface inside the tab bar interface.

Your simplest solution, though, might be to reconsider your interface.

matt
  • 515,959
  • 87
  • 875
  • 1,141
0

Like this:

How to handle UINavigationControllers and UITabBarControllers iOS 6.1

That's a more complicated version, but take a look at the Tab Bar Controller and it's relationship with it's contained viewControllers.

Basically you don't want your tabBarController to be embedded in that Nav Controller. Instead, each contained viewController that wants to push on should be embedded in it's own Nav Controller. So in your case you would at least do that for your first tab's tableViewController.

Community
  • 1
  • 1
foundry
  • 31,615
  • 9
  • 90
  • 125