MKMapView双击

时间:2014-12-19 18:41:23

标签: ios mkmapview uitapgesturerecognizer

以下是我的代码;我没有得到didDoubleTapMap解雇。

UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(didDoubleTapMap:)];
doubleTap.numberOfTapsRequired = 2;
doubleTap.numberOfTouchesRequired = 1;
[mkMapView addGestureRecognizer:doubleTap];


UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapOnMap:)];
singleTap.numberOfTapsRequired = 1;
singleTap.numberOfTouchesRequired = 1;


[singleTap requireGestureRecognizerToFail:doubleTap];

[mkMapView addGestureRecognizer:singleTap];

1 个答案:

答案 0 :(得分:3)

我缺少的是,

doubleTap.delegate = self;
singleTap.delegate = self;

另外不要忘记实施:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}