1.首先按住command点击MMDrawerController 进入其.h文件,在.h文件中添加可读写的BOOL型函数。
@property (nonatomic,assign)BOOL XZBBOOL;
2.在进入MMDrawerController.m文件 找到
-(BOOL)isPointContainedWithinCenterViewContentRect:(CGPoint)point 此函数整体换为下面的函数
替换为:
-(BOOL)isPointContainedWithinCenterViewContentRect:(CGPoint)point{
CGRect centerViewContentRect = self.centerContainerView.frame;
centerViewContentRect = CGRectIntersection(centerViewContentRect,self.childControllerContainerView.bounds);
if (self.XZBBOOL) {
return (CGRectContainsPoint(centerViewContentRect, point) &&[self isPointContainedWithinNavigationRect:point] == NO);
}else{
return NO;
}
}
3.在你使用时 得到MMDrawerController的指针
例如刚创建时
MMDrawerController * drawerController = [[MMDrawerController alloc]
initWithCenterViewController:_mainViewController
leftDrawerViewController:_leftDrawer
rightDrawerViewController:nil];
drawerController.XZBBOOL = YES;//设为YES是可以侧滑
如果在二级界面甚至三级界面,会有手势冲突这时我们可以如下:
注:可以给所有的二级甚至三级界面共同期继承一个基类,在基类中实现。 当返回到一级界面别忘了再重新打开呦!
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
MMDrawerController * drawerController = (MMDrawerController *)app.window.rootViewController;
drawerController.XZBBOOL = NO;
}