Reputation: 777
In the application I'm trying to develop I have UINavigationController as a root controller. I initialize views using pretty common code:
MySubclassOfViewController *vc = [[MySubclassOfViewController alloc]
initWithNibName:@"MySubclassOfViewController"
bundle:nil];
vc.title = @"A title";
[self.navigationController pushViewController:vc animated:YES];
[vc release];
After a succession of some views I want to load UITabBarController.
Is there a way to desing the nib file and create an instance of UITabBarController the same way as above?
I know I can do this programmatically or by explicitly declaring an outlet and connecting it with the controller in the nib. It's also possible to initialize the controller using something like
NSArray *objects = [[NSBundle mainBundle]
loadNibNamed:@"MySubclassOfViewController"
owner:self
options:nil];
self = [objects objectAtIndex:0];
[objects release];
But can I make it without extra work & typing?
Upvotes: 1
Views: 1034
Reputation: 777
I've solved my problem myself. After some research, I came to these conclusions.
UITabBarController *tbc = [[UITabBarController alloc] initWithNib...
) Either there should be an extra outlet for the controller, or the controller should be explicitly alloc
/init
'ed (but not initWithNibName
), or it could be instantiated using loadNibNamed
. That's it. The reason for this is that the tab bar controller doesn't have outlets declared to connect them to children view controller. (For more details on loading nibs check Development Chaos Theory blog).Any comments on this? :)
Upvotes: 1