hidesBottomBarWhenPushed ignored in iOS 7

匿名 (未验证) 提交于 2019-12-03 02:06:01

问题:

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?

回答1:

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.



回答2:

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];



回答3:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!