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:
Have you tried using setViewControllers(_ viewControllers: [UIViewController]?, animated animated: Bool)
instead of
tabBarController.viewControllers?.removeAll()
tabBarController.viewControllers?.append(tableViewNavController)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.