Search code examples
iosobjective-cuitabbarcontrollerios9pushviewcontroller

iOS 9.0 Tabbar hide automatically and viewcontroller disappear in push


I have a TabBarController with 4 Tab. When i push a ViewController from a tab then the tab is hidden automatically and its showing nothing in View. But ViewController contains a tableview with data. I have implemented tableview delegate also.I am not getting tableview delegate logs.

in appdelegate didFinishLaunchingWithOptions()

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

self.homeScreen = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.rootNav = [[UINavigationController alloc]initWithRootViewController:self.homeScreen];

self.window.rootViewController = self.rootNav;

[self.window makeKeyAndVisible];

Load TabBar here:

 myAppDelegate.myTabBarController.selectedIndex = 0;
myAppDelegate.myTabBarController.tabBar.translucent = NO;
myAppDelegate.myTabBarController.tabBar.opaque = YES;


location_select *tab1 = [[location_select alloc] initWithNibName:@"location_select" bundle:nil];
tab1.tabBarItem.image = [UIImage imageNamed:@"Restaurants.png"];
location_select *tab2 = [[location_select alloc] initWithNibName:@"location_select" bundle:nil];
tab2.title = @"Cart";
tab2.tabBarItem.image = [UIImage imageNamed:@"Cart.png"];
Deal_ViewController *tab3 = [[Deal_ViewController alloc] initWithNibName:@"Deal_ViewController" bundle:nil];
tab3.title = @"Deals";
tab3.tabBarItem.image = [UIImage imageNamed:@"Deals.png"];

MoreViewController *tab4 = [[MoreViewController alloc] initWithNibName:@"MoreViewController" bundle:nil];
tab4.title = @"More";
tab4.tabBarItem.image = [UIImage imageNamed:@"More.png"];
myAppDelegate.myTabBarController.viewControllers = [NSArray arrayWithObjects:tab1,tab2,tab3,tab4,nil];
[myAppDelegate.rootNav pushViewController:myAppDelegate.myTabBarController animated:YES];

From Tab 4, i push Profile_ViewController:

 Profile_ViewController *vc = [[Profile_ViewController alloc] initWithNibName:@"Profile_ViewController" bundle:[NSBundle mainBundle]];
 [self.navigationController pushViewController:vc animated:YES];

And already i applied there:

myAppDelegate.myTabBarController.hidesBottomBarWhenPushed=NO; 
and 
[self.tabBarController setHidesBottomBarWhenPushed:NO];

in viewWillAppear of Profile_ViewController. Nothings works. I just see a blank white screen.


Solution

  • location_select *tab1 = [[location_select alloc] initWithNibName:@"location_select" bundle:nil];
    tab1.tabBarItem.image = [UIImage imageNamed:@"Restaurants.png"];
    location_select *tab2 = [[location_select alloc] initWithNibName:@"location_select" bundle:nil];
    tab2.title = @"Cart";
    tab2.tabBarItem.image = [UIImage imageNamed:@"Cart.png"];
    Deal_ViewController *tab3 = [[Deal_ViewController alloc] initWithNibName:@"Deal_ViewController" bundle:nil];
    tab3.title = @"Deals";
    tab3.tabBarItem.image = [UIImage imageNamed:@"Deals.png"];
    
    MoreViewController *tab4 = [[MoreViewController alloc] initWithNibName:@"MoreViewController" bundle:nil];
    tab4.title = @"More";
    tab4.tabBarItem.image = [UIImage imageNamed:@"More.png"];
    
    
    
    
    UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:tab1];
    
    UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:tab2];
    
    UINavigationController *nav3 = [[UINavigationController alloc] initWithRootViewController:tab3];
    
    UINavigationController *nav4 = [[UINavigationController alloc] initWithRootViewController:tab4];
    
    myAppDelegate.myTabBarController.viewControllers = [NSArray arrayWithObjects:nav1,nav2,nav3,nav4,nil];
    [myAppDelegate.rootNav pushViewController:myAppDelegate.myTabBarController animated:YES];
    
    and then later on to push your vc to tab 4 you should do
    
    Profile_ViewController *vc = [[Profile_ViewController alloc] initWithNibName:@"Profile_ViewController" bundle:[NSBundle mainBundle]];
    [nav4 pushViewController:vc animated:YES];
    

    here is the Solution related to your query which might help you