Adding a UITabBarController to an UIViewController
I've got a sample application on http://github.com/niklassaers/Test-iPhone-TabBar-App that shows my problem: I have a regular view-based application, and at some point (in this case when I click a button) I want to load a tabbar controller and display it. I believe this is what I should be doing:
MyTabBarController *tabs = [[MyTabBarController alloc] initWithNibName:@"TabBar" bundle:nil];
[self.view addSubview:tabs.view];
Unfortunately, this brings up a bit of black in the bottom of my main view and nothing more. I believed it should bring up the tabbar, the tabs, and the select开发者_运维百科ed view. What is the correct way of loading a TabBarController (or making a TabBar controller if that's what I've done wrong) in a view-based application?
Cheers
Nik
You should use a UINavigationController, then just push the tabs controller onto the nav controller when you're ready to display it.
精彩评论