0

I am trying to implement MMDrawer to implement the left drawer but only in one view controller and it is not the root controller. On click of login button I should be able to redirect to another view controller having left drawer and centre view

Almost a similar question to Using MMDrawer only in sub navigation view

-(void) signInButtonListener:(UIButton *)button{

  UIViewController * leftDrawer = [[leftDrawerViewController alloc] init];
  UIViewController * center = [[centreViewController alloc] init];

  MMDrawerController * drawerController = [[MMDrawerController alloc]
                         initWithCenterViewController:center
                         leftDrawerViewController:leftDrawer
                         rightDrawerViewController:nil];

 [drawerController setShowsShadow:NO];
 [drawerController setRestorationIdentifier:@"MMDrawer"];
 [drawerController setMaximumRightDrawerWidth:200.0];
 [drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
 [drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];

 [drawerController
 setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
     MMDrawerControllerDrawerVisualStateBlock block;
     block = [[MMExampleDrawerVisualStateManager sharedManager]
              drawerVisualStateBlockForDrawerSide:drawerSide];
     if(block){
         block(drawerController, drawerSide, percentVisible);
     }
 }];

 landingPageViewController *landingPageController =  [UBNLandingPageViewController new];
 [myNavigator pushViewController:drawerController animated:YES];
}
Community
  • 1
  • 1
RonoKim
  • 184
  • 1
  • 16

1 Answers1

0

in AppDelegate.h

@property (strong, nonatomic) MMDrawerController *drawer;

in AppDelegate.m file inside:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {




 UIStoryboard *mainstory=[UIStoryboard storyboardWithName:@"Main" bundle:nil];

UIViewController * leftDrawer = [mainstory instantiateViewControllerWithIdentifier:@"MenuTableViewController"];

        UIViewController * center = [mainstory instantiateViewControllerWithIdentifier:@"HomeViewController"];

   UINavigationController *leftnav=[[UINavigationController alloc]initWithRootViewController:leftDrawer];
        UINavigationController *homnav=[[UINavigationController alloc]initWithRootViewController:center];
//drawer is the object for MMDrawerController
 drawer=[[MMDrawerController alloc]initWithCenterViewController:homnav leftDrawerViewController:leftnav rightDrawerViewController:nil];

//dont write

_window.rootViewController=drawController; [_window makeKeyAndVisible]; comment these lines if you write.

in ur LoginButtonAction

import AppDelegate.h file and write inside these lines then u will get centre view as a next page.

  AppDelegate *app=(AppDelegate *)[[UIApplication sharedApplication]delegate];
    app.window.rootViewController = app.drawer;
    [app.window makeKeyAndVisible];
NAVEEN KUMAR
  • 669
  • 6
  • 25