给UIPanGestureRecognizer添加代理(UIGestureRecognizerDelegate),UIGestureRecognizerDelegate中有一个方法:
-(BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldReceiveTouch:(UITouch*)touch;
在进入手势识别事件之前,先进入该方法,对那些不需要响应手势事件的事件,可以通过返回一个NO型布尔值不响应手势识别;而对于需要响应手势识别的情况,只需要返回一个YES就可以。
举例如下:
UIPanGestureRecognizer* panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];