2013-01-07 39 views
0

我想要导航堆栈中的导航应用程序有三个UIViewController。我有一个底栏(UITabBar)。Tabbar不会显示在导航堆栈中的某个UIViewController中

当第一个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]; 

现在的问题是,我可以得到UITabBar隐藏第一UIViewController的,但对于第二个它也是隐。

我该如何解决这个问题?

回答

1

而不是使用hidesBottomBarWhenPushed方法。试试你的代码隐藏的TabBarViewController,像

[self.tabBarController.tabBar setHidden:YES]; 

显示的TabBar

[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)] 
+1

你知道iPhone 5?更好地使用'self.view.frame.size.height'而不是480. –

+0

谢谢,它有帮助 –

相关问题