Reputation: 585
I have a story boar set up with a view that has a button. When I click that button I should go to a custom UITabBarController but all that is displayed is an empty Tab Bar.
let tabBar = TabViewController()
self.presentViewController(tabBar, animated: true, completion: nil)
In the story board I have set the class of the TabBarController to be a TabViewController. What am I missing?
Upvotes: 2
Views: 6356
Reputation: 130183
You need to give the TabViewController a storyboard ID in Interface Builder and get access to it via:
if let tabViewController = storyboard.instantiateViewControllerWithIdentifier("TheAssignedID") as? TabViewController {
presentViewController(tabViewController, animated: true, completion: nil)
}
The code you're using is just creating a new instance of the TabViewController class. Not accessing the prototype that you've defined in Interface Builder.
Upvotes: 5