Adding a side menu to your IOS App – RESideMenu Storyboard Tutorial Part 2

This is continuation from Part 1.

We have previously created the Storyboard, now we need to configure some settings.

RootViewController.h – Add the following codes

RootViewCodes

#import "RESideMenu.h"

@interface RootViewController : RESideMenu <RESideMenuDelegate

RootViewController.m – Add the following codes

- (void)awakeFromNib
{
    self.menuPreferredStatusBarStyle = UIStatusBarStyleLightContent;
    self.contentViewShadowColor = [UIColor blackColor];
    self.contentViewShadowOffset = CGSizeMake(0, 0);
    self.contentViewShadowOpacity = 0.6;
    self.contentViewShadowRadius = 12;
    self.contentViewShadowEnabled = YES;
    
    self.contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"contentViewController"];
    self.leftMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"left"];
    self.backgroundImage = [UIImage imageNamed:@"Stars"];
    self.delegate = self;
}

#pragma mark -
#pragma mark RESideMenu Delegate

- (void)sideMenu:(RESideMenu *)sideMenu willShowMenuViewController:(UIViewController *)menuViewController
{
    NSLog(@"willShowMenuViewController: %@", NSStringFromClass([menuViewController class]));
}

- (void)sideMenu:(RESideMenu *)sideMenu didShowMenuViewController:(UIViewController *)menuViewController
{
    NSLog(@"didShowMenuViewController: %@", NSStringFromClass([menuViewController class]));
}

- (void)sideMenu:(RESideMenu *)sideMenu willHideMenuViewController:(UIViewController *)menuViewController
{
    NSLog(@"willHideMenuViewController: %@", NSStringFromClass([menuViewController class]));
}

- (void)sideMenu:(RESideMenu *)sideMenu didHideMenuViewController:(UIViewController *)menuViewController
{
    NSLog(@"didHideMenuViewController: %@", NSStringFromClass([menuViewController class]));
}

Take note of the leftMenuViewController in the awakeFromNib method. We going to set those identifier to our storyboard’s viewcontroller.

Storyboard – RootViewController

Set the class to RootViewController.

SetClassforRootView

Storyboard –¬†NavigationViewController

Set the StoryboardID to contentViewController.

 

SetNavigationControllerStoryboardID

 

Storyboard – HomeViewController

  1. Set both the Class and Storyboard ID.

SetClassandIDforHomeController

2. Now add a UIBarItem to your navigation.

BarButtonItem

3. Link the UIBarItem with the presentLeftMenuAction.

Linkthemup

 

Now you are good to test! Ping me up if you have issue.

Leave a Reply

Your email address will not be published. Required fields are marked *