我想抓住UIGestureRecognizer
. 我可以这样做吗?
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
NSLog(@"Gesture should begin");
if ([gestureRecognizer isMemberOfClass:[UIRotationGestureRecognizer class]])
NSLog(@"rotate");
if ([gestureRecognizer isMemberOfClass:[UIPinchGestureRecognizer class]])
NSLog(@"pinch");
if ([gestureRecognizer isMemberOfClass:[UITapGestureRecognizer class]])
NSLog(@"tap");
if ([gestureRecognizer isMemberOfClass:[UIPanGestureRecognizer class]])
NSLog(@"pan");
if ([gestureRecognizer isMemberOfClass:[UILongPressGestureRecognizer class]])
NSLog(@"long");
if ([gestureRecognizer isMemberOfClass:[UISwipeGestureRecognizer class]])
NSLog(@"swipe");
return NO;
}
我在表格视图单元格中有一个长触摸手势。如果我按下单元格,我会收到一条日志:
-[FileObjectView gestureRecognizerShouldBegin:] [Line 45] Gesture should begin
-[FileObjectView gestureRecognizerShouldBegin:] [Line 55] long
我希望它以这种方式工作。
但有时当我滚动表格视图时,我会收到一条日志:
-[FileObjectView gestureRecognizerShouldBegin:] [Line 45] Gesture should begin
这让我觉得我不知道某种手势。
有人能解释一下情况吗?