views:

655

answers:

1

I'm trying to create a navigation view in the Interface Builder. It's not in the MainWindow.xib, so the relevant sample project on the Apple Dev. site is useless.

The most logical (and cleanest) way to approach this seems to create a Xib-file where the File's Owner is a subclass of UINavigationController - however, I cannot get this to work at all in IB, (because UINavigationController acts as a folder, and File's Owner doesn't, even when I change the class).

Alternatively, I've got a Xib-file where the File's owner is a subclass of a normal ViewController (VCA). I've added a NavigationController with a ViewController that's another subclass of UIViewController (VCB), and I've specified a Xib view for this ViewController. But I have no idea how to specify the view of VCA in IB, and my attempts to do this programmatically haven't worked.

Please help!

A: 

I've had trouble doing things like this when I was getting started and the most workable approach I came up with was to create the UINavigationController programmatically. I adapted my code from the iPhone "utility" Xcode template. Here's a bit of it that will hopefully get you going: (edited for brevity; self is a UIViewController)

self.menuViewController = [[[MenuViewController alloc] 
                 initWithNibName:nil bundle:nil] autorelease];

self.navController = [[UINavigationController alloc] 
     initWithRootViewController:self.menuViewController];

self.navController.navigationBar.barStyle = UIBarStyleBlackOpaque;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[self.view addSubview:self.navController.view];
[UIView commitAnimations];
Adam Preble