King
King

Reputation: 2025

making a Tabbar controller rootViewController

I have an application where a user can login or signup. If a user is logged in, I want to present a viewcontroller but the challenge I have now is that the view controller is in a Tabbar controller. How do I navigate to the Tabbar controller.

func goToMainPageVC () {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let mainPageVC = storyboard.instantiateViewController(withIdentifier: Constants.PAGE_VC)
        window?.rootViewController = mainPageVC

    }

this is my code but this only presents the viewcontroller without the navigationItems or Tabbar

Upvotes: 1

Views: 107

Answers (1)

Shehata Gamal
Shehata Gamal

Reputation: 100533

You need to set the identifier to the tabBarController not to it's main vc

let tab = storyboard.instantiateViewController(withIdentifier:"tab") as! UITabBarController
window?.rootViewController = tab 

Upvotes: 1

Related Questions