0

i use Firebase Notification in my iOS App. When i click the notification then opening Second View Controller but Tab Bar doesn't seem. Only Navigation Controller and Table View seems.

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)

2 Answers2

0

You are presenting a new instance of your second view controller modally from the tab bar controller. This isn't probably what you want. Instead just select proper (second) tab in your existing tab bar controller, see Switching to a TabBar tab view programmatically?

You may need to update some data in that tab or you can completely replace the controller for that tab.

algrid
  • 5,600
  • 3
  • 34
  • 37
0
 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()