views:

1522

answers:

1

I have a UITabBarController based application. The tabs will be created from database entries, so I don't know them in advance. I'd like to programmatically initialize a UINavigationController subclass (I have a few different kinds) for each tab.

Ideally, I would really like to draw the whole UINavigationController subclass + it's subview using Interface Builder, just like you can do when you add define the view for each tab in IB (that's when you know what the tabs will be in advance). I've tried setting the "Class identity" to my UINavigationController subclass name, then add a UINavigationController inside it, but obviously it didn't inject the instance at the "File's owner" level...

Thanks

+2  A: 

I've ended up not subclassing UINavigationController, it appears it isn't what's recommended. I quickly realized that there wasn't a whole lot of benefit from designing the UINavigationController's from within IB. Instead, I subclassed UIViewController, wrote the few lines of init for theUINavigationBar (custom buttons, custom middle image) in my viewDidLoad. It's just better to simply wrap the subclass with [[UINavigationController alloc] initWithRootController: subclass]; when I programmatically fill my tabs. Subclassing UINavigationControllerdirectly prevented me from properly using the navigationItem property of my inject view.

François P.