2012-10-24 36 views
3

我想趕上UIGestureRecognizer的類型。 我可以這樣做嗎?UIGestureRecognizer類型catch在gestureRecognizerShouldBegin

- (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 

這讓我覺得,我不知道某些類型的手勢。

can anybode可以解釋情況嗎?

+0

雅,它爲我工作.. – Avinash

回答

1

我決定檢查類名是這樣的:

NSLog(@"%@",gestureRecognizer.class); 

類名稱爲:UIScrollViewPanGestureRecognizer

我已經檢查這個問題很多次在differen的iOS版本。

這件事情只發生在iOS 6上。還有一個iOS 6的bug?