美文网首页
uiscrollview 侧滑返回失效

uiscrollview 侧滑返回失效

作者: 超_iOS | 来源:发表于2019-06-20 14:43 被阅读0次

uiscrollview 侧滑返回失效

    self.scrollV.panGestureRecognizer.delegate = self;

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    
    // 开启侧滑返回功能
    
    // 是否为平移手势
    if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
        // 获取平移方向
        CGPoint translation = [(UIPanGestureRecognizer *)gestureRecognizer translationInView:gestureRecognizer.view];
        // 向右滑动 && scrollView滑动到最左侧
        if (translation.x >= 0 && self.scrollV.contentOffset.x <= 0) {
            return YES;
        }
    }
    return NO;
}

相关文章

网友评论

      本文标题:uiscrollview 侧滑返回失效

      本文链接:https://www.haomeiwen.com/subject/uezdqctx.html