一般来说,UIGestureRecognizer对象不会将本身已经处理过的触摸事件再交给其它的UIGestureRecognizer对象处理,例如:想实现先通过长按选择屏幕上的线条,然后再拖动,由于前述UIGestureRecognizer对象的特性,实际效果是只能识别长按手势,而无法识别之后的拖动手势。
要处理这个问题,就需要用到UIGestureRecognizerdelegate来解决了,例子如下:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)other {
if (gestureRecognizer == panRecognize) {
return YES;
}
return NO;
}