Storyboard MMDrawerController library

So, I recently met this pretty neat library, MMDrawerController . I managed to install it and initialize it using the code below in appDelegate.m.

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

UIViewController * leftSideDrawerViewController = [[LeftViewController alloc] init];

UIViewController * centerViewController = [[CenterViewController alloc] init];

UIViewController * rightSideDrawerViewController = [[RightViewController alloc] init];

UINavigationController * navigationController = [[UINavigationController alloc] initWithRootViewController:centerViewController];
[navigationController setRestorationIdentifier:@"MMExampleCenterNavigationControllerRestorationKey"];

self.drawerController = [[MMDrawerController alloc]
                         initWithCenterViewController:navigationController
                         leftDrawerViewController:leftSideDrawerViewController
                         rightDrawerViewController:rightSideDrawerViewController];
[self.drawerController setRestorationIdentifier:@"MMDrawer"];
[self.drawerController setMaximumRightDrawerWidth:200.0];
[self.drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
[self.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];

[self.drawerController
 setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
     MMDrawerControllerDrawerVisualStateBlock block;
     block = [[MMExampleDrawerVisualStateManager sharedManager]
              drawerVisualStateBlockForDrawerSide:drawerSide];
     if(block){
         block(drawerController, drawerSide, percentVisible);
     }
 }];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window setRootViewController:self.drawerController];


  return YES;
}

However, everything in my storyboard is now covered in black (caused by the code above the "override" of the storyboard xml code) when I create the application. How can I integrate this library correctly with the storyboard?

+4
source share
4 answers

What follows should be done: -

1) 3 .

2) , "", "" = > " " = > " "

3) github: -

https://github.com/mutualmobile/MMDrawerController MMDrawerController Zip .

4) github , " ": -

  • MMExampleDrawerVisualStateManager.h
  • MMExampleDrawerVisualStateManager.m
  • MMDrawerBarButtonItem.h
  • MMDrawerBarButtonItem.m
  • MMDrawerController.h
  • MMDrawerController.m
  • MMDrawerController + Subclass.h
  • MMDrawerVisualState.h
  • MMDrawerVisualState.m
  • UIViewController + MMDrawerController.h
  • UIViewController + MMDrawerController.m

5) , AppDelegate.m didFinishLaunchingWithOptions : -

Objective-C

UIStoryboard *storyboard;

storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController * leftSideNavController =
[storyboard instantiateViewControllerWithIdentifier:
 @"leftViewController"];

UIViewController * centerSideNavController =
[storyboard instantiateViewControllerWithIdentifier:
 @"ViewController"];

UIViewController * rightSideNavController =
[storyboard instantiateViewControllerWithIdentifier:
 @"rightViewController"];



self.drawerController =
[[MMDrawerController alloc]
 initWithCenterViewController:centerSideNavController
 leftDrawerViewController:leftSideNavController
 rightDrawerViewController:rightSideNavController];

[self.drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
[self.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];


[self.window setRootViewController:self.drawerController];
/* Optional - To define Drawer width */
[self.drawerController setMaximumRightDrawerWidth:280.0];

[self.drawerController setMaximumLeftDrawerWidth:280.0];

[self.window makeKeyAndVisible];

Swift 2.2

let mainStoryBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let centerVC = mainStoryBoard.instantiateViewControllerWithIdentifier("Home") as! HomeVC

let leftVCs = mainStoryBoard.instantiateViewControllerWithIdentifier("Left") as! LeftVC

let rightVCs = mainStoryBoard.instantiateViewControllerWithIdentifier("Right") as! RightVC

let rightSideNav =  UINavigationController(rootViewController: rightVCs)
let leftSideNav =  UINavigationController(rootViewController: leftVCs)

let centerSideNav = UINavigationController(rootViewController: centerVC)

centerContainer = MMDrawerController(centerViewController: centerSideNav, leftDrawerViewController: leftSideNav, rightDrawerViewController: rightSideNav)

centerContainer!.openDrawerGestureModeMask = MMOpenDrawerGestureMode.PanningCenterView
centerContainer!.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.PanningCenterView
                  centerContainer?.setDrawerVisualStateBlock(MMDrawerVisualState.swingingDoorVisualStateBlock())

window!.rootViewController = centerContainer
window!.makeKeyAndVisible()

. var centerContainer: MMDrawerController? AppDelegate Swift.

+5

" ". - ,

UINavigationController * navigationController = [[UINavigationController alloc] 
    initWithRootViewController:centerSideNavController];
self.drawerController = [[MMDrawerController alloc]
     initWithCenterViewController:navigationController
     leftDrawerViewController:leftSideNavController
     rightDrawerViewController:rightSideNavController];

, -.

+3

, , .

+1

Source: https://habr.com/ru/post/1539696/


All Articles