zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

iOS隐藏和显示tabBar

ios 显示 隐藏 tabBar
2023-09-11 14:14:25 时间

方案1:

使用self.tabBarController.tabBar.hidden来控制当前页面tabBar的显示和隐藏

self.tabBarController.tabBar.hidden = YES;

方案2: 

使用hidesBottomBarWhenPushed来控制push出来页面tabBar的显示和隐藏

UIViewController *ctrl = [[UIViewController alloc] init];
ctrl.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController: ctrl animated:YES];
 

问题:UITabBarController从根页面push到下级页面后,确认下级页面的hidesBottomBarWhenPushed已经设置为YES,当下级页面的输入框收起键盘时,tabBar会再次出现。

解决方案1:(iOS12)

[[UITabBar appearance] setTranslucent:NO];

解决方案2:

当使用self.tabBarController.tabBar.hidden后,再调用hidesBottomBarWhenPushed,push出来的页面键盘隐藏时tabBar会再次出现,避免同时使用这两种隐藏tabbar的方案。