Navjot Singh Navjot Singh - 3 months ago 9
Swift Question

Segue Presently from Appdelegate to UITabBarController in swift

I want to segue from

AppDelegate
to First View of
UITabBarController
.
I assigned
StoryBoardID
of
UITabBarController
as "HomePage".

and I tried below code:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController: UITabBarController = storyboard.instantiateViewControllerWithIdentifier("HomePage") as! UITabBarController

let rootViewController = self.window!.rootViewController as! UINavigationController
rootViewController.pushViewController(viewController, animated: true)


It works but I gave
BackBarButton
on destination view which I don't want.
I want to segue Presently.

Answer

You need to set your viewControllers instead of pushViewController

rootViewController.viewControllers = [viewController]

Instead of

rootViewController.pushViewController(viewController, animated: true)