Tab Bar Application With Navigation Controller

Adrian Collins picture Adrian Collins · Dec 15, 2008 · Viewed 69.3k times · Source

I have a simple iPhone app that has a tab bar and 3 tabs. Each tab loads as a separate 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.

Answer

Kendall Helmstetter Gelner picture Kendall Helmstetter Gelner · Dec 15, 2008

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 the navigation controller inside the tab bar controller, then drag your existing view controller inside the navigation controller.

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.