Search code examples
iosobjective-cuitabbar

Tab bar not appearing


The tab bar for this project isn`t showing up, instead it just shows a black screen.This tab bar is enter in pragmatically in application launch in app delegate.

main_tab=[[UITabBarController alloc]init];
viewcontroller = [[HomeViewController alloc]init];
viewcontroller.title =@"Home";
UINavigationController *nav =[[UINavigationController alloc]initWithRootViewController:viewcontroller];

viewcontroller1 = [[SearchViewController alloc]init];
viewcontroller1.title =@"Search";
UINavigationController *nav1 =[[UINavigationController alloc]initWithRootViewController:viewcontroller1];


tabs_array=[[NSArray alloc]initWithObjects:nav,nav1, nil];
main_tab.viewControllers=tabs_array;
[self.window addSubview:main_tab.view];
[self.window makeKeyAndVisible];

return YES;

Solution

  • Try replacing this line

       [self.window addSubview:main_tab.view];
    

    With this

        self.window.rootViewController = main_tab;