【问题标题】:show tab bar on pop using hidesBottomBarWhenPushed使用 hidesBottomBarWhenPushed 在 pop 上显示标签栏
【发布时间】:2017-06-06 14:37:48
【问题描述】:

我只想在父控制器上显示标签栏,而不是在任何子控制器上。

我正在推送:

childViewController?.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(childViewController!, animated: true)

现在,当我通过单击“返回”按钮向后导航时,该栏再次显示在父级上。

但是如果我像这样以编程方式做同样的事情:

childViewController?.hidesBottomBarWhenPushed = true
self.navigationController?.popToRootViewController(animated: true)
//or
self.navigationController?.popViewController(animated: true)

然后标签栏不再显示在父级上。

我已经尝试了很多解决方案,例如;

解决方案 1: 用孩子写这段代码

- (void)viewWillAppear:(BOOL)animated { 
    self.hidesBottomBarWhenPushed = true 
}
- (void)viewWillDisappear:(BOOL)animated {
    self.hidesBottomBarWhenPushed = false 
}

解决方案 2:在 push 上编写此代码

childViewController?.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(childViewController!, animated: true)
childViewController?.hidesBottomBarWhenPushed = false

这些都不起作用。如果我使用导航栏后退按钮导航回来,一切正常。 但是如果我popViewControllerpopToRootViewController 那就不行了。

使用:XCode 8.3.2、Swift 3

请帮帮我。提前谢谢你。

【问题讨论】:

    标签: uitabbarcontroller popviewcontrolleranimated


    【解决方案1】:

    在要隐藏的控制器中使用这种方式:

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
        self.hidesBottomBarWhenPushed = true
    }
    

    【讨论】:

      猜你喜欢
      • 2017-08-14
      • 2012-01-19
      • 2020-06-08
      • 2015-10-29
      • 1970-01-01
      • 2020-08-31
      • 2018-01-20
      • 2023-03-06
      • 1970-01-01
      相关资源
      最近更新 更多