views:

1142

answers:

2

I've got a UITabController. One of the tabs is a UINavigationController. Pushing and popping the navigation stack works just fine. Every UIViewController has his own NIB with just the UIView hooked up. But unfortunately I only get a title displayed for the root navigation controller!

Usually when creating a UIViewController in a NIB you have a title attribute that you can set. But in this case the view controller is the NIB file owner. And in IB there is no way to set the title.

What I can do is to set the title in initWithNib and then it shows up.

if (self = [super initWithNibName: @"MyViewController" bundle:nil]) {
    self.title = @"test";
}

But I want to define the title in IB.

I am a bit lost here. Any suggestions?

+1  A: 
h4xxr
Indeed. And that's how I set the title of the **root* controller. The question is about the other controllers that get pushed on top. Up until now I only know how to change their title in code as IB does not expose the title attribute on the file owner.Open up e.g. the "Completed" NIB. That's where it gets interesting for me.
tcurdt
The UITabController in your example is the *root* controller. The Navigation controller essentially is the same object as different view pass underneath it, which is why if you want to set a title for subviews you need to do so in code. You don't have to call it in the init method however - just self.title=@"test" will do it in any of the UIViewController delegate methods.
h4xxr
The navigation controller manages view controllers (not subviews - not directly at least). I was referring to the root view controller that is handled by the navigation controller. When a view controller is pushed onto the navigation stack the title of the view controller is displayed. As the NIB creates the view controller instance, it should be possible to set the title in IB. Up until now I don't see a way of doing that. THAT is the problem.
tcurdt
A: 

So apparently their is no way to set the title of the UIViewController in this scenario. Too bad.

tcurdt