在写项目时,发现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>
网友评论