10

我有一个tabBar + NavigationViewController。选项卡栏有细胞收集视图(说厂景),并用细胞推送seague被实现为另一个视图(说视图2)。隐藏标签栏在推视图

视图2我想有一个navBar但没有标签栏。

我试图

self.tabBarController?.tabBar.hidden = true

视图2工作得很好,但是当我回到厂景通过后退按钮的标签仍然是隐藏的(即使是在后view1 I级新增self.tabBarController?.tabBar.hidden = falseviewDidLoad func)。

我该如何让标签栏重新出现在view1

我在swift工作。

回答

19

viewDidload设置的UIViewController hidesBottomBarWhenPushed为yes:

self.hidesBottomBarWhenPushed = YES; 

这样的UINavigationController需要隐藏标签栏的照顾。

+0

我已经在代码“视图2添加了此“class fun viewDidLoad但它不工作...是否有任何其他方式 – 2014-11-06 13:52:05

+0

抱歉..代码是写在View2中,所以它不工作...现在我将代码移到view1类和选项卡隐藏在View2中,但是当我回到view1它不得到显示.. – 2014-11-06 13:54:50

+0

谢谢它现在开始工作..感谢很多 – 2014-11-06 14:08:22

19

使用在prepareforsegue

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
if ([segue.identifier isEqualToString:@"showRecipeDetail"]) { 
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; 
    RecipeDetailViewController *destViewController = segue.destinationViewController; 
    destViewController.recipeName = [recipes objectAtIndex:indexPath.row]; 

    // Hide bottom tab bar in the detail view 
    destViewController.hidesBottomBarWhenPushed = YES; 
}} 

=)

+0

这是唯一对我有用的答案。 – 2015-03-22 16:10:13

16

布鲁诺·费尔南德斯的答案斯威夫特:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 
    if segue.identifier == "YourSegueIdentifier" { 
     let destinationController = segue.destinationViewController as! YourViewController 
     destinationController.hidesBottomBarWhenPushed = true 
    } 
} 

这是为我工作的答案。将hidesBottomBarWhenPushed置于viewDidLoad方法中不起作用。

谢谢布鲁诺!

+0

错字,控制器应该是:'destinationController.hidesBottomBarWhenPushed = true' – 2016-07-23 15:53:59

+0

修正了它。感谢您指出亚瑟。 – 2016-09-12 13:12:31

+0

这应该是正确的答案,谢谢! – 2017-09-15 22:17:50

12

enter image description here

试着检查你的控制器!

0

,如果你想隐藏TabBarController底酒吧:#Swift 3

在YourViewController:在viewDidLoad中()方法

self.tabBarController?.tabBar.isHidden = false