代码之家  ›  专栏  ›  技术社区  ›  Yannis

在navigationController中按控制器时如何隐藏父选项卡栏

  •  22
  • Yannis  · 技术社区  · 16 年前

    我有一个带有选项卡栏控制器的应用程序,每个视图都包含一个导航控制器。我的主窗口如下所示: Image here http://www.freeimagehosting.net/image.php?7bc867a594.png

    一切正常,因为它是,但我注意到一个问题时,推动一个细节视图导航控制器。在属于选项卡栏控制器(图像中称为Latest的控制器)的tableviewcontroller的DidSelectRowatingIndexPath中,我正在执行以下操作:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        ArticleViewController *articleController = [[ArticleViewController alloc] initWithNibName:@"ArticleView" bundle:nil];
    
        [self.navigationController pushViewController:articleController animated:YES];
    
        [articleController release];
        articleController = nil;
    }
    

    提前谢谢

    7 回复  |  直到 7 年前
        1
  •  95
  •   Yannis    16 年前

    在花了几个小时在这里发布了一个问题之后,我发现这个问题的解决方案是在ArticleController的实例化之后添加以下行。

    articleController.hidesBottomBarWhenPushed = YES;
    
        2
  •  34
  •   Viktor Kucera    10 年前

    如果你更喜欢故事板配置而不是编码,有一个切换。只需转到destinationViewController>属性检查器:

    enter image description here

        3
  •  17
  •   Mrinal Mandal    13 年前

    一个非常简单的解决方案:

     destinationViewController.hidesBottomBarWhenPushed = YES;
    

     articleController.hidesBottomBarWhenPushed = YES;
    

    希望这有帮助!

        4
  •  5
  •   Deep    9 年前

    您可以通过情节提要简单地隐藏父选项卡栏。

    选择 &燃气轮机; &燃气轮机; 按下时隐藏底部栏

        5
  •  4
  •   Teena nath Paul    8 年前

    您可以在正在推送的视图控制器中添加以下代码。

    -(BOOL)hidesBottomBarWhenPushed
    { 
         return YES;
    }
    

    这将仅在推送的视图控制器中隐藏选项卡栏,并且当您弹出视图控制器时,选项卡栏将在rest所有视图控制器中保持取消隐藏状态。

    override var hidesBottomBarWhenPushed: Bool {
        get {
            return navigationController?.topViewController == self
        }
        set {
            super.hidesBottomBarWhenPushed = newValue
        }
    }
    

    谢谢

        6
  •  1
  •   Nits007ak    9 年前

    enter image description here

    转到Xcode中的interface builder->打开属性检查器并选中不想显示选项卡栏的视图控制器的“按下时隐藏底部栏”项。会有用的!!

        7
  •  1
  •   Haroldo Gondim smargo    7 年前

    hidesBottomBarWhenPushed 在要隐藏的控制器中。

    prepare for segue

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        segue.destination.hidesBottomBarWhenPushed = true
    }
    
        8
  •  1
  •   aturan23 DairySeeker    5 年前

    对于swift3,在如下所示的pushviewController代码之前,通过取消隐藏tabbar来编写相同的代码

    var frame = self.tabBarController?.tabBar.frame
    frame?.origin.y = self.view.frame.size.height - (frame?.size.height)!+112
    UIView.animate(withDuration: 0.2, animations: {
      self.tabBarController?.tabBar.frame = frame!
    })
    self.navigationController?.pushViewController(viewController, animated: true)
    

    或者使用whant来打开你可以使用的tabbar

    viewController.hidesBottomBarWhenPushed = false
    
    推荐文章