我有一个视图,它有一个UIPanGestureRecognizer
. 同一个视图还包含一个UIScrollView
.
当用户平移 ScrollView 时,我返回 NO in gestureRecognizerShouldBegin:
,以确保 ScrollView 的手势识别器接管手势。
但是,我仍然收到gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:
消息。很容易解决,我只需要在中返回NO gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:
,但是我想知道在返回NO后收到这个消息是否正常gestureRecognizerShouldBegin:
。
代码
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
NSLog(@"gestureRecognizerShouldBegin:0x%x - return NO", (int)gestureRecognizer);
return NO;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
NSLog(@"gestureRecognizer:0x%x shouldRecognizeSimultaneouslyWithGestureRecognizer:0x%x", (int)gestureRecognizer, (int)otherGestureRecognizer);
return YES;
}
输出
2013-03-04 11:30:14.876 XXXX[99271:19d03] gestureRecognizerShouldBegin:0x9d6c380 - return NO
2013-03-04 11:30:14.876 XXXX[99271:19d03] gestureRecognizer:0x9d6c380 shouldRecognizeSimultaneouslyWithGestureRecognizer:0xbb75240