MMDrawerController 使用遇到的问题及定制

MMDrawerController

1,
集成
UIViewController * leftDrawer = [[UIViewController alloc] init]; UIViewController * center = [[UIViewController alloc] init]; UIViewController * rightDrawer = [[UIViewController alloc] init]; MMDrawerController * drawerController = [[MMDrawerController alloc] initWithCenterViewController:center leftDrawerViewController:leftDrawer rightDrawerViewController:rightDrawer];

详细代码

 

    tabVC = [[TabBarController alloc]init];

    

    //左边页面框架

    LeftPage *leftController = [[LeftPage alloc] init];

    

    

    self.drawerController = [[MMDrawerController alloc]

                             initWithCenterViewController:tabVC

                             leftDrawerViewController:leftController

                             rightDrawerViewController:nil];

    [self.drawerController setShowsShadow:NO];

    [self.drawerController setRestorationIdentifier:@"MMDrawer"];

    [self.drawerController setMaximumLeftDrawerWidth:260.0];

    // self.drawerController.visibleLeftDrawerWidth = 260;

    [self.drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];

    [self.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];

    //侧滑推出风格

    [[MMExampleDrawerVisualStateManager sharedManager] setLeftDrawerAnimationType:1];

    

    [self.drawerController

     setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {

         MMDrawerControllerDrawerVisualStateBlock block;

         

         block = [[MMExampleDrawerVisualStateManager sharedManager]

                  drawerVisualStateBlockForDrawerSide:drawerSide];

         if(block){

             block(drawerController, drawerSide, percentVisible);

         }

     }];

    [self.window setRootViewController:self.drawerController];


重新定义主界面左上角按钮 事件

-(void)leftBtnPressed

{

   // [[(AppDelegate *)[[UIApplication sharedApplication] delegate] menuController] showLeftController:YES];

    [self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];

}

当点击左边头像回到主界面的时候,想回到主界面,demo是又重新创建的一个新的,在项目中不可取。


2,当主界面进入二级页面,想去除手势。实现定制。

MMDrawerController.h 添加 

/* 2016-5-10 mxt 添加

  是否开启手势滑动出菜单*/

@property (assign,nonatomic) BOOL needSwipeShowMenu;//是否开启手势滑动出菜单

 

MMDrawerController.m 添加 

 

 

#pragma mark - Helpers

-(void)setupGestureRecognizers{

    

    pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureCallback:)];

    [pan setDelegate:self];

    

    //[self.view addGestureRecognizer:pan];

    

    

    tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureCallback:)];

    [tap setDelegate:self];

    [self.view addGestureRecognizer:tap];

}

// 重写sett

- (void)setNeedSwipeShowMenu:(BOOL)needSwipeShowMenu{

    _needSwipeShowMenu = needSwipeShowMenu;

    if (needSwipeShowMenu) {

       // NSLog(@"--------needSwipeShowMenu---------------------------------- yes  ");

        [self.view addGestureRecognizer:pan];

    }else{

       // NSLog(@"--------needSwipeShowMenu---------------------------------- no  ");

          [self.view removeGestureRecognizer:pan];

    }

}

 

在使用的页面 添加 

 

- (void)viewDidAppear:(BOOL)animated

{

    [super viewDidAppear:animated];

    NSLog(@" mine viewDidAppear  yes");

    kAPPDelegate.drawerController.needSwipeShowMenu = YES;  

}

- (void)viewWillDisappear:(BOOL)animated

{

    kAPPDelegate.drawerController.needSwipeShowMenu = NO;

}

 

 








posted @ 2016-05-11 11:08  mengxiangtong22  阅读(3339)  评论(0编辑  收藏  举报