Reputation: 4270
So this piece of code is called after authenticating the users login details:
func completeLogin() {
dispatch_async(dispatch_get_main_queue(), {
let tabBarController = self.storyboard!.instantiateViewControllerWithIdentifier("PostLoginTabBarController") as! UITabBarController
let tableViewController = self.storyboard!.instantiateViewControllerWithIdentifier("InformationTableViewController") as! InformationTableViewController
let tableViewNavController = UINavigationController(rootViewController: tableViewController)
tabBarController.viewControllers?.removeAll()
tabBarController.viewControllers?.append(tableViewNavController)
self.presentViewController(tabBarController, animated: true, completion: nil)
})
}
In my storyboard:
I have the PostLoginTabBarController
that has a relationship with 2 other ViewControllers
My question is:
Is there a better way than removing all the View Controllers
that the PostLoginTabBarController
has and then adding the new instantiated ones in the completeLogin()
method? The reason I am doing this is because if I sever the relationship between the PostLoginTabBarController
when the PostLoginTabBarController
is presented it shows a black screen, but if I don't sever the relationship then it is fine.
Here is an example when I sever the relationship:
And when I don't:
Upvotes: 0
Views: 24
Reputation: 10294
Have you tried using setViewControllers(_ viewControllers: [UIViewController]?, animated animated: Bool)
instead of
tabBarController.viewControllers?.removeAll()
tabBarController.viewControllers?.append(tableViewNavController)
Upvotes: 3