Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hidesBottomBarWhenPushed ignored in iOS 7

This code was working well until iOS 7 release. I'm assigning a UIViewController, with hidesBottomBarWhenPushed as YES, as the rootViewController of an UINavigationController. But the TabBar is being shown anyway. Here's the relevant code:

Login *lv = [[Login alloc] init];
lv.HowToUseShows = showHowToUse;
lv.hidesBottomBarWhenPushed = YES;

UINavigationController *BokShelfNav = [[UINavigationController alloc] initWithRootViewController:lv];

//... 

UITabBarController *tbController = [[UITabBarController alloc] init];
tbController.viewControllers = @[BokShelfNav,...];

Anyone with a similar problem?

like image 701
JP Illanes Avatar asked Sep 27 '13 09:09

JP Illanes


3 Answers

I found that the order in which methods are called and properties are set has an impact on whether the tab bar is shown.

If I put self.hidesBottomBarWhenPushed = YES; in the viewDidLoad method of the view controller I'm pushing the tab bar still shows. If I moved it to the init method the tab bar hides as it used to on iOS 6.

like image 97
Adam Swinden Avatar answered Oct 23 '22 21:10

Adam Swinden


The only workaround I've found is to make the tabBarController start in another tab ([tbController setSelectedIndex:1];), and then, in the viewWillAppear: method of that tab ViewController do [tbController setSelectedIndex:0];

like image 24
JP Illanes Avatar answered Oct 23 '22 21:10

JP Illanes


I have set setSelectedIndex after push statement and it worked.

//created tabbar controller object

if(index==0)
    [tabbarcontroller setSelectedIndex:1];

[self.navigationcontroller pushViewcontroller:tabbarcontroller anmated:YES];
[tabbarcontroller setSelectedIndex:index];

The only issue is if you are showing your controller at 0th index in that it will show. In this case I have first set mt tabbarcontroller's index as 1(different from 0). And its working.

like image 22
Piyush Hirpara Avatar answered Oct 23 '22 20:10

Piyush Hirpara