【问题标题】:Tab Bar doesn't seem when i use rootViewController当我使用 rootViewController 时,标签栏没有出现
【发布时间】:2017-09-21 19:44:21
【问题描述】:

我在我的 iOS 应用中使用 Firebase 通知。当我单击通知然后打开第二个视图控制器但选项卡栏似乎没有。似乎只有导航控制器和表格视图。

enter image description here

        let rootViewController = self.window!.rootViewController as! UITabBarController
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let secondViewController = storyboard.instantiateViewController(withIdentifier: "SecondViewController") as! UINavigationController
        rootViewController.present(secondViewController, animated: false)

【问题讨论】:

    标签: ios swift firebase swift3


    【解决方案1】:

    您正在从标签栏控制器模态显示第二个视图控制器的新实例。这可能不是你想要的。相反,只需在现有标签栏控制器中选择正确的(第二个)标签,请参阅Switching to a TabBar tab view programmatically?

    您可能需要更新该选项卡中的一些数据,或者您可以完全替换该选项卡的控制器

    【讨论】:

      【解决方案2】:
       let controller =
                  self.storyboard?.instantiateViewController(withIdentifier: "TabBarViewController") as! TabBarViewController
       let secondViewController =   self.storyboard?.instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController
      
       controller.setViewControllers([secondViewController], animated: true)
       let del = UIApplication.shared.delegate as! AppDelegate
       del.window?.rootViewController = controller
       del.window?.makeKeyAndVisible()
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-10-01
        • 1970-01-01
        • 2017-01-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多