UINavigationControllers and Interface Builder


After spending some quality time with Homepwner I’m pretty comfortable with the programmatic approach to UINavigationController. I understand that UIViewControllers have a ToolbarItems and NavigationItem that basically populates the views of the Navigation Bar. Now I’d like to take that knowledge and get my hands dirty in Interface Builder.

I started by checking out the Apple documentation on View Controllers… pretty standard stuff about Navigation Controllers here. I was particularily interested in this part about Navigation Controllers and NIB files

Then I went over to the Interface Builder documentation and started digging for how to setup an IB project for Navigation Controllers. That relevant documentation is here.

Between those two documents, the template for a UINavigationController app, and some of Apple’s example code, I’m not sure I’m getting it.

From what I can gather, I need to have all of my UIViewController subclasses “instantiated” (by dragging those objects from the library into the document viewer) in the XIB that also contains my Navigation Controller instance? Apple documentation for IB says that you create separate XIBs for your View Controllers, but doing exactly as they say can’t be right (their XIB has a File’s Owner of type NSObject).

Any chance I could get some help getting this sorted out?


Setting up a navigation controller in Interface Builder is so convoluted it isn’t even worth knowing. I couldn’t give you the step-by-step off the top of my head, it is entirely too many steps that don’t particularly make sense.

The general idea, however, is that a XIB file has not only archived view objects but all of the controller objects are archived as well (so yes, dragging those objects onto the Doc window). Therefore, all of the view controllers will be instantiated when the XIB file is loaded.

I cannot for the life of me figure out why Apple thinks it is okay to instantiate controller objects in IB. It really makes maintaining a project more difficult and there are some obscure little behavior problems that pop up when you do it this way. But, it sure does make for a great demo. :slight_smile: