在viewDidLoad添加一下代码即可:
// 更换interactivePopGestureRecognizer的delegate,这里设置为controller自己,
self.interactivePopGestureRecognizer.delegate =self;
//开启右滑Pop手势
self.interactivePopGestureRecognizer.enabled = YES;
//处理手势冲突
[self resolvePopGesture];
//把scrollview的panGestureRecognizer 与 UIScreenEdgePanGestureRecognizer做绑定,当panGestureRecognizer遇到UIScreenEdgePanGestureRecognizer冲突时,panGestureRecognizer自动失效。
- (void)resolvePopGesture{
NSArray *gestures = self.navigationController.view.gestureRecognizers;
for (UIGestureRecognizer *gesture in gestures) {
if ([gesture isKindOfClass:[UIScreenEdgePanGestureRecognizer class]]) {
[self.scollView.panGestureRecognizer requireGestureRecognizerToFail:gesture];
}
}
}
就是这么简单就可以完美解决scrollView与右滑pop的手势冲突了。喜欢这么干货的文章,请为我点赞哦。