Search code examples
iosiphoneobjective-cios5uitabbarcontroller

Moving from a view controller to a tab bar controller when using storyboards ioS5


I created a tab bar controller in a story board which is working perfect. Now i need to move from a view controller to this tab bar controller. I do not have a separate class for the tab bar controller. However I tried creating a class for this tab bar controller but when i call it/initialise it, it just gives a new tab bar instead of whats on the storyboard. Ive been stuck with this for a while now so any help would be appreciated. So application works this way. viewcontroller1 -> viewcontroller2 -> tabbarcontroller (which has a table view and a map view)


Solution

  • If I understand your question correctly, what you want to do is assign an identifier to the TabBarController in the Storyboard, in the Attributes Inspector, and then use that to programmatically instantiate the controller using this code:

    UITabBarController *tabBarController = [self.storyboard instantiateViewControllerWithIdentifier:@"TabBarIdentifer"];