我正在尝试创建一个基于导航的应用程序,在导航堆栈中具有三个 UIViewController
。我有一个底部栏(UITabBar
)。
我想在第一个 UIViewController
被插入堆栈时隐藏选项卡栏,并且我想在第二个 UIVIewController
被插入堆栈时显示选项卡栏。
这是我为此编写的代码。
对于第一个UIVIewController
:
NotificationDetailsVC *obj = [[NotificationDetailsVC alloc] init];
obj.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:obj animated:YES];
[obj release];
对于第二个UIViewController
我已经完成了:
NotificationBO *obj=[self.notificationsArray objectAtIndex:indexPath.row];
object.hidesBottomBarWhenPushed = NO;
[self.navigationController pushViewController:object animated:YES];
[object release];
现在的问题是,我可以为第一个 UIViewController 隐藏 UITabBar,但对于第二个 UIViewController,它也被隐藏。
我该如何解决这个问题?
最佳答案
而不是使用hidesBottomBarWhenPushed
方法。尝试在 ViewController
中隐藏选项卡栏代码,例如
[self.tabBarController.tabBar setHidden:YES];
以及显示标签栏
[self.tabBarController.tabBar setHidden:NO];
上面的方法可以工作,但问题是它会在 viewController
底部留下一个空白。要解决这个问题,请将 frame
设置为 tabbarController
。
对于隐藏,设置
[self.tabBarController.tabBar setFrame:CGRectMake(0, 480, 320, 50)]
对于显示,设置
[self.tabBarController.tabBar setFrame:CGRectMake(0, 430, 320, 50)]
关于iphone - 导航堆栈中的某些 UIViewController 中未显示选项卡栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14196026/