【发布时间】:2016-04-01 10:02:44
【问题描述】:
好的,这里有情况:
我有注释标记,当我点击其中一个时,它会调用方法
- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MYCustomAnnotationView *)view
然后我从 (MYCustomAnnotationView *)view 中获取一些属性的值,并根据它们进行一些动作。
只有双击注释时才需要做这个动作。
我做了什么:
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTapOnAnnotationView)];失败,因为我需要发送(MYCustomAnnotationView *)view。我试图存储最后命中的注释,但它似乎不是正确的方式。UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] performSelector:@selector(doubleTapOnAnnotationView:mapView:) withObject:view withObject:mapView];但它不起作用。tapCount++; switch (tapCount) { case 1: //single tap [self performSelector:@selector(singleTap:) withObject: nil afterDelay: 0.2]; break; case 2: //double tap [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(singleTap:) object:nil]; [self performSelector:@selector(doubleTap:) withObject: nil]; break; default: break; } if (tapCount>2) tapCount=0;但它不适用于此方法。
我想我需要像completionHandler这样的东西,双击时。也许有人知道在这种情况下有什么帮助?
【问题讨论】:
-
您可以访问处理点击手势的视图:
-(void)doubleTapOnAnnotationView:(UITapGestureRecognizer *)tap{MyCustomAnnotationView *annotationView = tap.view;},并使用@selector(doubleTapOnAnnotationView:) -
这是正确的答案。有效!
标签: ios objective-c xcode cocoa-touch mkmapview