Fatima
Fatima

Reputation: 464

side menu with UITabBarController and storyboards ios

I would like to implement a side menu bar in my application, I have UITabBarController and Storyboard, I have tried to integrate the menu bar MFSideMenu , but there is not a menu with UITabBarController for storyboard, just for nib files, so I need your help. Many thanks

Upvotes: 0

Views: 872

Answers (1)

Schrodingrrr
Schrodingrrr

Reputation: 4271

You simply do the following:

  • Create a UIStoryboard instance of the the relevant storyboard you need to set as the center controller, in case you have multiple storyboards. Use HomeStoryboard if you have just the standard storyboard in use.
  • Instantiate the view controller that is the initial view controller of your app, based on it's storyboard ID. You will have to set this in Storyboard (utilities pane).
  • Instantiate the view controller you want to use as the left menu.
  • Create an instance of MFSideMenuContainerViewController, with the center and left(or right, or both) menu controller you just created.
  • Set the instance of your MFSideMenuContainerViewController as the rootViewController of your app window.

Sample code:

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"HomeStoryboard" bundle:nil];

UIViewController *homeViewController = [sb instantiateViewControllerWithIdentifier:@"homeViewController"];

UIViewController* leftMenuViewController = ......//Instantiate your left menu controller

MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController
                                                        containerWithCenterViewController:homeViewController
                                                        leftMenuViewController:leftMenuViewController
                                                        rightMenuViewController:nil];
self.window.rootViewController = container;
[self.window makeKeyAndVisible];

Upvotes: 4

Related Questions