views:

187

answers:

2

Is it possible to have more than one UITabbarController in a single iPhone application?

My application has more than one sections, each section needs to have its own UITabbarController to navigate with in that section. New section is to be loaded if a certain type of item is selected from previous section. Secondly the Back button in navigation bar should also perform they it does, if the user is on the first controller of the second section that was pushed if he presses the button he should go back to the first section showing its UITabbarcontroller.

A: 

Sure, use a UINavigationController to push and pop your UITabbarController instances. When the user selects an item from a UITabbarController, push the next one into your UINavigationController, and when the Back button is pressed, it will pop it back out, and reveal your previous UITabbarController.

luvieere
I have created a UITababrController in application delegates applicationDidFinishLaunching method and for each of its tab item I have associated a UINavigationController each having a UIViewController as a root controller. When the second tab item is clicked I push another tabbarcontroller, but it is viewed over the last tabbarcontroller. I am trying it at different events but its not working properly.Where should I push the the tabbarcontroller. If you can provide some sample code it will be great. :)
Ali Awais
I have tried it using different ways:1. The second item of tab bar has a UITabbarcontroller associated with it.2. A navigation controller is associated with each tabbar item. When the second tabbar button is pressed the navigation controller associated with the second loads a view controller and pushes a UITabbarController.Also tried 1 or 2 other ways. But the navigation bars are added below each other similarly tabbarcontroller are added one above the other.
Ali Awais
A: 

You could probably get this to work in your scenario if your tab controllers are at the same level, ie they are not nested (I think nesting them will end up causing lots of problems).

So if you have a top level that does not have a tab controller, but when the user selects something, the second level down DOES have a tab controller, you can probably make that work.

What I would suggest you do is have a top level Tab Bar Controller as you would in a normal tab bar application. Give it one tab entry, your top level navigation controller. And HIDE the tab bar at the root level.

When the user selects an item and you push a view controller, just push it like normal, and as it displays configure your top tab controller to have the tabs you want, and unhide it. When the user pops the view, hide the tab controller again and release the unwanted tabs.

Then do the same for all of your other selections. So you only ever have one tab controller, but to the user it looks like you have one per section.

Hope this helps.

theLastNightTrain
Yes my tab bar controllers were at the same level, and i assign the default tab bar to the main navigation controller then i push or pop other tab bars when required from the main navigation controller
Ali Awais