原文链接:http://blog.csdn.net/hjaycee/article/details/49279951#0-tsina-1-90689-397232819ff9a47a7b7e80a40613cfe1
直接上解决办法:
1.首先自定义一个scrollView,比如:CustomScrollView,遵守<UIGestureRecognizerDelegate>协议,然后在实现文件中写如下代码:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
// 首先判断otherGestureRecognizer是不是系统pop手势
if ([otherGestureRecognizer.view isKindOfClass:NSClassFromString(@"UILayoutContainerView")]) {
// 再判断系统手势的state是began还是fail,同时判断scrollView的位置是不是正好在最左边
if (otherGestureRecognizer.state == UIGestureRecognizerStateBegan && self.contentOffset.x == 0) {
return YES;
}
}
return NO;
}
2.那个横向滚动的scrollView继承这个自定义scrollView,也就是CustomScrollView
原理:
scrollView的pan手势会让系统的pan手势失效,所以我们只需要在系统手势失效且scrollView的位置在初始位置的时候让两个手势同时启用就可以了