解决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
推荐阅读
- 急于表达——往往欲速则不达
- parallels|parallels desktop 解决网络初始化失败问题
- 第三节|第三节 快乐和幸福(12)
- 20170612时间和注意力开销记录
- 2.6|2.6 Photoshop操作步骤的撤消和重做 [Ps教程]
- 对称加密和非对称加密的区别
- 眼光要放高远
- 考研英语阅读终极解决方案——阅读理解如何巧拿高分
- 樱花雨
- 前任