解决MMDrawerController和UIScrollView手势冲突

【解决MMDrawerController和UIScrollView手势冲突】当MMDrawerController的centerViewController添加UIScrollView的时候,滑动打开抽屉就失效了。我在网上找到这篇帖子https://www.2cto.com/kf/201608/543321.html跟我的问题类似,虽然我使用他的方法并没有奏效,不过按照他的思路我最终还是解决了我的问题。
解决办法是写一个UIScrollView的子类,并实现UIGestureRecognizerDelegate中的方法

@implementation CJScrollView- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer {if([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) { return YES; } return [super gestureRecognizerShouldBegin:gestureRecognizer]; }- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizer {if ([gestureRecognizer isKindOfClass:NSClassFromString(@"UIScrollViewPanGestureRecognizer")] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {if(self.contentOffset.x==0.0f) { //这里返回YES,gestureRecognizer和otherGestureRecognizer互斥时,gestureRecognizer会失效 return YES; } } return NO; }@end

    推荐阅读