我正在尝试在导航堆栈中创建一个基于导航的应用程序,其中包含三个UIViewController
。我有一个底栏(UITabBar
)。
我希望在第一个UIViewController
被推入堆栈时隐藏tabbar,并且我想在推送第二个UIVIewController
时显示tabbar。
以下是我编写的代码。
首先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 Hidden,但是第二个它也是隐藏的。
我该如何解决这个问题?
答案 0 :(得分:1)
而不是使用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)]