【问题标题】:Issue in hiding TabBar in the pushed ViewController, TabBar appearing after some delay在推送的 ViewController 中隐藏 TabBar 的问题,TabBar 在一些延迟后出现
【发布时间】:2019-03-08 01:01:56
【问题描述】:

TabBar 没有隐藏在推送的 ViewController 中,我用下面的代码隐藏了 tabBar,

tabBarController?.tabBar.isHidden = true
                or
self.hidesBottomBarWhenPushed = true

但经过一段时间的延迟后,tabBar 仍然出现。如果有人遇到这种问题,并且能够解决它。你的回答会很有帮助。

我在故事板中也这样做了。

【问题讨论】:

    标签: ios swift uitabbarcontroller ios11


    【解决方案1】:

    如果你想隐藏特定控制器上的 tabor,你可以这样做:

    controller.hidesBottomBarWhenPushed = true

    【讨论】:

    • 您好,感谢您的回答。我已经做了所有隐藏 tabBar 的方法,包括你的答案。当我进入屏幕时,TabBar 将被隐藏。但一段时间后它又出现了。这是我面临的问题。
    • controller 引用的是你推送的那个,而不是 tabbarcontroller
    【解决方案2】:

    您需要做的只是选择要为其隐藏 Bar 的 ViewController 的“Hide bottom bar on push”属性。请检查屏幕截图。注意:以编程方式编写“self.hidesBottomBarWhenPushed = true”有时对我不起作用。

    【讨论】:

    • 嗨,Naresh,我这样做了,但没有奏效。导航栏仍然显示。
    • 导航栏还是TabBar?
    • 标签栏。不是导航栏
    【解决方案3】:

    UITabBarController 拥有hidesBottomBarWhenPushed 属性,因此您必须在要推送的控制器上设置true

    例如:

        //pushedVC - VC you try to push(the one where you don't want to show TabBar)
        pushedVC.hidesBottomBarWhenPushed = true
        navigationController?.pushViewController(pushedVC, animated: true)
    

    Storyboard中设置这个

    Documentation

    【讨论】:

    • 您好安德鲁,感谢您的回答。我已经做了所有隐藏 tabBar 的方法,包括你的答案。当我进入屏幕时,TabBar 将被隐藏。但一段时间后它又出现了。这是我面临的问题。
    • @RamprasadA 看看更新的答案。您应该将其属性设置为 ViewController 您尝试推送。希望对您有所帮助。
    • @RamprasadA 你在哪里做这个动作tabBarController?.tabBar.isHidden = true,在viewWillAppear
    • @RamprasadA 尝试使用断点检查viewDidAppear 内的tabBarController?.tabBar.isHidden 值。我几乎可以肯定它在某个地方发生了变化。导致这个流程看起来很奇怪。
    • 我只在一个地方设置它,在屏幕上没有我设置 tabBar isHidden 属性的地方。这个问题很麻烦。
    猜你喜欢
    • 2017-01-28
    • 2015-09-26
    • 1970-01-01
    • 1970-01-01
    • 2017-06-14
    • 2019-10-27
    • 2012-01-31
    • 2021-06-04
    • 1970-01-01
    相关资源
    最近更新 更多