UIScrollView滑动与自带右滑手势冲突 解决方案

2017-11-09  本文已影响3人  厦门_小灰灰

自定义UIScrollView,然后实现协议

<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;
} 

OK。本文不是自创,只是做笔记;

上一篇下一篇

猜你喜欢

热点阅读