我在网上看到了很多关于它的问题,尤其是在 StackOverflow 上。我测试了许多给定的答案,但就我而言,没有任何效果。
我的班级实现了协议UIGestureRecognizerDelegate
:
@interface CDMapViewController : CDViewController <UIGestureRecognizerDelegate>
以下方法是从我的类的@implentation 中的xcode 自动完成编写的
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldReceiveTouch:(UITouch *)touch {
NSLog(@"not called");
return NO;
}
我在第一个方法中正确地初始化了 UIGestureRecognizer,它正确地调用了第二个、第三个和第四个方法:
- (void)initGestureOnMap {
UIGestureRecognizer *gestureRecognizer = [[UIGestureRecognizer alloc] init];
gestureRecognizer.delegate = self;
[self.view addGestureRecognizer:gestureRecognizer];
}
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
gesture_dragging = NO;
}
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesMoved:touches withEvent:event];
gesture_dragging = YES;
}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesEnded:touches withEvent:event];
if (gesture_dragging || [touches count] != 1) return;
/* bla bla bla */
}
...它不记录-不调用...为什么?