【问题标题】:hidesBottomBarWhenPushed not working in swifthidesBottomBarWhenPushed 不能快速工作
【发布时间】:2021-07-18 06:27:48
【问题描述】:

在我的项目中,我使用 hidesBottomBarWhenPushed 作为

尝试 1:

  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let vc =  AppStoryboard.Chat.instance.instantiateViewController(withIdentifier: "ChatDetailViewController") as! ChatDetailViewController
        vc.hidesBottomBarWhenPushed = true
        navigationController?.pushViewController(vc, animated: true)
    }

但 tabBar 仍然可见。

试过 2

我也试过tabBar.isHidden,但没有用。

试过 3

在我使用的 TabBarController 类中 hidesBottomBarWhenPushed = true

【问题讨论】:

  • self.tabBarController?.tabBar.isHidden = true

标签: ios swift tabbar


【解决方案1】:

试试这个

 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let vc =  AppStoryboard.Chat.instance.instantiateViewController(withIdentifier: "ChatDetailViewController") as! ChatDetailViewController
        self.hidesBottomBarWhenPushed = true
        navigationController?.pushViewController(vc, animated: true)
    }

【讨论】:

    【解决方案2】:

    试试这个会很好用

    navigationController.hidesBottomBarWhenPushed = true
    

    【讨论】:

    • 您是否在 TabBarController 和 ViewController 之间添加了导航控制器?
    • 如果没有那么请在你的故事板中添加一个navigationController 选择你的viewController 然后去Editor --> Embed In -->NavigationController ....,它会在它们之间添加一个navigationController,然后尝试使用此代码。它会工作
    猜你喜欢
    • 2016-03-21
    • 2014-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    相关资源
    最近更新 更多