Reputation: 381
How to create a tabbar Controller and Navigation Bar Controller in a window based app? I am trying to include both controllers.
Upvotes: 3
Views: 368
Reputation: 11
You can also do it in the Interface Builder, just make sure the Tabbar controller is the root/master controller and inside it you can add as many navControllers as you need. Of course, the tabbar controller is the one added to the Window in the AppDelegate.m file.
I you dont want the tabbar to be visible from the begining, you can implement self.tabbarcontroller.tabbar.hidden = YES;
in the viewDidLoad or viewWillAppear
methods of each of the views you dont want the tabbar on.
Upvotes: 0
Reputation: 1885
Instead of viewcontrollers, add navigation contollers as each item for the tabbarcontroller.
Upvotes: 0
Reputation: 1692
You can do this as follows... Create project of navigationController type.. then in AppDelegate , create a tabBarController. Have an array of you Viewcontrollers as follows...
mTabBar = [[UITabBarController alloc] init];
NSMutableArray *localViewControllersArray = [[NSMutableArray alloc] initWithCapacity:3];
TSDetailTaskController *mTSDetailTaskController = [[TSDetailTaskController alloc]initWithNibName:@"TSDetailTaskController" bundle:nil];
UINavigationController *mTaskNavBar=[[UINavigationController alloc]initWithRootViewController:mTSDetailTaskController];
mTaskNavBar.tabBarItem.title=@"Task List";
mTaskNavBar.tabBarItem.image =[UIImage imageNamed:@"glyphicons_114_list.png"];
[mTSDetailTaskController release];
mTSSearchController=[[TSSearchController alloc]initWithNibName:@"TSSearchController" bundle:nil];
UINavigationController *mSearchNavBar=[[UINavigationController alloc]initWithRootViewController:mTSSearchController];
mSearchNavBar.title=@"Search";
mSearchNavBar.tabBarItem.image=[UIImage imageNamed:@"glyphicons_009_search.png"];
[mTSSearchController release];
TSSettingController *mTSSettingController = [[TSSettingController alloc]initWithNibName:@"TSSettingController" bundle:nil];
UINavigationController *mSettingNavBar=[[UINavigationController alloc]initWithRootViewController:mTSSettingController];
mSettingNavBar.tabBarItem.title=@"Setting";
mSettingNavBar.tabBarItem.image=[UIImage imageNamed:@"glyphicons_280_settings.png"];
[mTSSettingController release];
[localViewControllersArray addObject:mTaskNavBar];
[localViewControllersArray addObject:mSearchNavBar];
[localViewControllersArray addObject:mSettingNavBar];
[mTaskNavBar release];
[mSearchNavBar release];
[mSettingNavBar release];
mTabBar.viewControllers = localViewControllersArray;
mTabBar.view.autoresizingMask==(UIViewAutoresizingFlexibleHeight);
[localViewControllersArray release];
[window addSubview:mTabBar.view];
[self.window makeKeyAndVisible];
return YES;
hope this will help you out..
Upvotes: 1