UISwipeGestureRecognizer与UIPanGe

2017-02-09  本文已影响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>

上一篇下一篇

猜你喜欢

热点阅读