Search code examples
iosobjective-camslidemenumfslidemenu

Slide-Out Navigation Panel in ios from scratch


I want to build a Slide out Navigation panel for both side (left & right) with segue. Some of the things i have to follow in this case. The left & right side menu table must be in UIViewController (not in UITableViewController) & all of the viewController is navigate through UINavigationController (Embedded).

I already try a ton of examples, But all of them are done by UITableViewController. Because of that i can't customize my left or right side Menu table according to my design.

If any one can give me some reference or similar tutorials, that would be very appreciable.

Thanks a lot in advanced. Have a good day.


Solution

  • you can use MMDrawcontroller and Pass LeftView, RightView and Centerview with Navigationcontroller. All three controllers are UIViewController. You can also add Left and Right View with NavigationController same as CenterView so you can push from left and right view.

    CenterVC *objCenter = [[CenterVC alloc] initWithNibName:@"CenterVC" bundle:nil];
    LeftVC *objleftVC = [[LeftVC alloc] initWithNibName:@"LeftVC" bundle:nil];
    RightVC *objrightVC = [[RightVC alloc] initWithNibName:@"RightVC" bundle:nil];
    
    /*--- Init navigation for Center Controller ---*/
    UINavigationController *_navC = [[UINavigationController alloc] initWithRootViewController:objCenter];
    _navC.navigationBarHidden = YES;
    _navC.navigationBar.translucent = NO;
    MMDrawerController *drawerController = [[MMDrawerController alloc]
                                            initWithCenterViewController:_navC
                                            leftDrawerViewController:objleftVC
                                            rightDrawerViewController:objrightVC];
    [drawerController setShowsShadow:NO];
    [drawerController setRestorationIdentifier:@"MMDrawer"];
    [drawerController setMaximumLeftDrawerWidth:[[UIScreen mainScreen] bounds].size.width-45.0];
    [drawerController setMaximumRightDrawerWidth:[[UIScreen mainScreen] bounds].size.width-45.0];
    [drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
    [drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
    [drawerController setShouldStretchDrawer:NO];
    
    [drawerController
     setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
         MMDrawerControllerDrawerVisualStateBlock block;
         block = [[MMExampleDrawerVisualStateManager sharedManager]
                  drawerVisualStateBlockForDrawerSide:drawerSide];
         if(block){
             block(drawerController, drawerSide, percentVisible);
         }
     }];
    
    
    [self.navigationController pushViewController:drawerController animated:isAnimate];
    

    Using Storyboard download (https://github.com/TomSwift/MMDrawerController-Storyboard) . Add MMDrawerController+Storyboard and then Replace or check Storyboard which was used in above demo and add code in AppDelegate as per demo.

    So your demo project will look like below image

    enter image description here