tags:

views:

11232

answers:

5

Hi

I have a simple iPhone app that has a tab bar and 3 tabs. Each tab loads a a seperate nib with a corresponding controller. Each nib contains a tableview with some other controls for searching/filtering etc.

What I would like (and cant seem to find an example of) is adding a navigation controller to the app so each nib (i.e. each tab) can drill down to further detail pages.

Should I be adding a navigation controller to the main window and creating an IBOutlet for it or should the NC be added to the nibs.

Any thoughts or example code would be much appreciated!

Thanks

+16  A: 

Once you have a tab bar in a XIB, the easiest way to approach this is to drag a UINavigationController object over from the Library window (looks like a left nav bar button on a gold background) into the Tree View for your tab bar (the text only view, not the GUI). Place it under the tab bar, then drag your existing view controller under the tab bar controller instead of under the tab bar.

When you go to view that tab you should then see a navigation bar on the top of it... if you are loading the navigation controller from another xib, you'll modify the nav bar in the tab bar xib.

Kendall Helmstetter Gelner
My vote up! This is the best trick to do it. Thanks. :)
Chintan Patel
+2  A: 

The way to think about it is this:

You want each tab to have a navigation controller. Then, each nav controller needs to have a root view controller and a loaded Nib.

So, in IB, add nav controllers for each of your tabs. Then, configure each nav controller to have the appropriate root view controller and Nib.

August
+3  A: 

I realized this is late, but this question is #1 on google results today and so I figured I'd add an answer. There is a great youtube video tutorial by O'Reilly that walks you through a tabbar + navigation controller app. Check it out here: http://www.youtube.com/watch?v=LBnPfAtswgw

dnstevenson
A: 

The tutorial is for the old version of xcode... Somebody knows if there´s an updated version?

Doenitz