+1  A: 

I believe you are looking for something like this. You would replace "whatever" with the name of you second nib file.

newNavController = [[UINavigationController alloc] initWithNibName:@"whatever" bundle:[NSBundle mainBundle]];
Joe Cannatti
I'd like to avoid having to load, initialize and release nibs programmatically. UITabBarController does that automatically (for plain UIViewControllers at least...)
porneL
+3  A: 

I haven't tried setting up UINavigationController via IB. I have multiple screens, each is stored in separate xib and there's a corresponding class that extends UIViewController. In applicationDidFinishLaunching I initialize UIViewControllers using xib's but then manually create UINavigationController, add navigation controller's view to window and push first view to navigation controller.

Not sure if that helps.

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    navigationController = [[UINavigationController alloc] init];

    FirstViewController * viewController = [[FirstViewController alloc] 
                                           initWithNibName:@"FirstView"
                                                    bundle:nil];
    [navigationController pushViewController:viewController animated:NO];
    [viewController release];
    [window addSubview:navigationController.view];
    [window makeKeyAndVisible];
}

Above FirstViewController extends UIViewController, in IB you create your view then set File's owner class to your class (e.g. here FirstViewController) and connect the File's owner view to the UIView's view.

stefanB
+1  A: 

First, it looks like you have your UITabBarItems under the navigation controllers instead of directly under the UITabBarController. That may be part of your problem.

Second, when you add a UITabBarController in IB and and click on its icon in your list of top-level objects (your first screenshot), the attributes inspector will allow you to change the type of view controller for each of the tabs. Using this, you can change them all to navigation controllers, if you wish. Also, since you wanted to load custom views and view controllers from other nibs, if you look at the "View Controller" section at the bottom of the attributes inspector, you can select a nib from your project to load the view from. Assuming that nib's "File's Owner" is set to your UINavigationController subclass, it should all work fine.

All of this without a large amount of coding work, either. Let me know if you'd like screenshots for what I'm talking about in case you can't find these panels.

Marc W
I can't move UITabBarItems directly under UITabBarController - that creates new controllers in IB.I've corrected types of controllers in UITabViews inspector and this triggered warning in IB which says it won't work :(
porneL
+5  A: 

Simply swap the UINavigationController with the FirstViewController.

So the hierarchy should be like this:

Tab bar controller
-----Tab bar
-----Navigation Controller
----------First View Controller
---------------Navigation Item
----------Tab bar item (First)
-----Navigation Controller
----------Second View Controller
---------------Navigation Item
----------Tab bar item (Second)

You set the nib of First View Controller in the inspector to the nib file containing the actual view objects (Since you are trying to split them into separate files, which is a good thing).

You have one tab, that tab has a navigation controller which loads First View Controller as its root view.

Done.

Corey Floyd
A: 

Hello, did you ever find a solution?

BobC
See update at top of my question and Corey's answer. Eventually I've learned to use `loadView` and `layoutSubviews` methods and now I prefer to create all views programmatically :)
porneL