美文网首页
UISwipeGestureRecognizer与UIPanGe

UISwipeGestureRecognizer与UIPanGe

作者: 傲弛天下 | 来源:发表于2017-02-09 16:55 被阅读0次

    在写项目时,发现UISwipeGestureRecognizer不进监听方法,换成Tap手势可以进去。经检查,原因是之前代码中已经添加了Pan手势,Pan手势将Swipe手势拦截掉了。解决方法是,设置手势的优先级
    <pre>
    //新加滑动手势
    UISwipeGestureRecognizer *detailSwipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)];
    detailSwipeRight.direction = UISwipeGestureRecognizerDirectionRight;
    [demoView addGestureRecognizer:detailSwipeRight];

        //取出之前的Pan手势,设置优先级,避免手势冲突
        UIPanGestureRecognizer *panGes = [_headView.gestureRecognizers objectAtIndex:0];
        [panGes requireGestureRecognizerToFail:detailSwipeRight];
    

    </pre>

    相关文章

      网友评论

          本文标题:UISwipeGestureRecognizer与UIPanGe

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