I have 2 viewcontrollers in a tabbar controller i am trying to open the first viewcontroller, showing the whole tabbar from scene delegate
i have
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyBoard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
self.window?.rootViewController = viewController
self.window?.makeKeyAndVisible()
Main is the storyboard and ViewController is the file for the first ViewController
with this, I see the first view controller, but I can't see the tabbar options
thanks in advance
CodePudding user response:
To do this, you need to instantiate the UITabBarController
- not your first view controller.
In your storyboard
, give your UITabBarController
an identifier just like you did for your ViewController
After doing that, replace this line:
let viewController
= storyBoard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
with
let viewController
= storyBoard.instantiateViewController(withIdentifier: "YourTabBarControllerIdentifier") as! UITabBarController
I believe this should work as you intended then