I currently have a UINavigationController in my app delegate where i push a ViewController on to login. If the login is successful i want to then create a UITabBarController with a Navigation Controller as the first Tab whose root controller is a UIViewController that i am creating.

The RootViewController of my first UINavigationController is actually acting as a delegate to the logincontroller so if a user logs in correctly it calls a method in my RootViewController which is where i would then like to push a UITabBarController onto the stack. Here is my code:

UITabBarController *tbController = [[UITabBarController alloc] init];
    FileBrowserViewController *fileController = [[FileBrowserViewController alloc]   init];
    fileController.pathToFileDB = pathToDBUnzipped;
    fileController.parentId = @"0";

    UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:fileController];

    NSMutableArray *aViewControllersArray = [[NSMutableArray alloc] initWithCapacity:2];
    [aViewControllersArray addObject:navController];
    [navController release];

    [tbController setViewControllers:aViewControllersArray];

    [self.navigationController pushViewController:tbController animated:YES];

    [tbController release];

Now, it is all working fine. Except 2 things. Here is the screen shot: My iPHone

1) I cant see any uitabbar items. How do i set an image and the text for each tab? 2) I dont want that top black bar. I only want 1 bar ontop with the undo button. How do i remove the additional bar?

Thanks for all the help!

4 Answers

saadnib On Best Solutions

to hide the above black bar use -

[self.navigationController setNavigationBarHidden:TRUE];

to set tab bar item use -

for system item -

UITabBarItem *firstItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:0];

for custom item -

UITabBarItem *firstItem = [[UITabBarItem alloc] initWithTitle:@"title" image:[UIImage imageNamed:@""] tag:0];

[navController setTabBarItem:firstItem];
Evan Johnson On

Here is a good video on how to combine Tab Bar, Navigation Bar, and/or Table Views.


If you don't want you sign-up screen to have a Tab Bar controller, then you will have to present it as a modal view (since the tab bar is your root view controller). This can be done through the presentModalViewController:animated: method. You can find info about that at:


I hope that helps. Let me know if you have any other questions!

Cheers, Evan.

vijay adhikari On

hi friend that top bar is status bar . You can set.statusbar hidden = yes; or change it from plist , when you open your plist there is a option to hide it,

Nitish On

I always follow this approach when I have both a UINavigationController and a UITabbarController:
You need to start with a view based application. And then create a UITabbarController in your appDelegate file.


UITabBarController *tabBarController;
// set properties


// Synthesize

tabBarController = [[UITabBarController alloc] init];

// Adding Search,Nearby,Map,AboutUs,Favorites Tabs to tabBarController  
Search * search = [[Search alloc] init];  
UINavigationController *searchNav = [[UINavigationController alloc]        initWithRootViewController:search];  

Nearby* nearby = [[Nearby alloc] init];  
UINavigationController *nearbyNav = [[UINavigationController alloc] initWithRootViewController:nearby];  

Map* map = [[Map alloc] init];  
UINavigationController *mapNav = [[UINavigationController alloc] initWithRootViewController:map];  

AboutUs* aboutUs = [[AboutUs alloc] init];  
UINavigationController *aboutUsNav = [[UINavigationController alloc] initWithRootViewController:aboutUs];  

Favorites* favorites = [[Favorites alloc] init];  
UINavigationController *favoritesNav = [[UINavigationController alloc] initWithRootViewController:favorites];  

NSArray* controllers = [NSArray arrayWithObjects:searchNav,nearbyNav,mapNav,aboutUsNav,favoritesNav, nil];  
tabBarController.viewControllers = controllers; 

[window addSubview:tabBarController.view];    

You can accordingly manage in which tab you want to place navigation controller or only a view controller.

Then in each of the view controllers mentioned above you need to implement

- (id)init {}

in which you can set Tab name and image.

I always follow this approach and it never fails. The tabs are always visible. You can make changes according to your code.