iphone - 如何检测 map 注释 Pin 上的点击?

标签 iphone google-maps ios4 mapkit

我想检测对注释引脚(mapkit)的点击,以便我可以对该事件执行操作。

现在,如果我触摸注释引脚,就会弹出默认注释标志。我想自定义它以在触摸 pin 时调用我的方法。

最佳答案


您需要实现以下委托(delegate)方法

 (MKAnnotationView) mapView viewForAnnotation:(id) annotation  

然后只需在该方法中声明以下内容

MKPinAnnotationView *view=[[MKPinAnnotationView alloc]initWithAnnotation:annotation  reuseIdentifier:@"abc"];
view.canShowCallout=YES;
view.calloutOffset=CGPointMake(-20,10); //As per your choice

然后您可以将 UI 添加到标注中,例如 UIButton 或 UIImage 作为 view.rightCalloutAccessoryView View.leftCalloutAccesoryView

关于iphone - 如何检测 map 注释 Pin 上的点击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5648169/

相关文章:

iphone - 声音无法在 iOS 中播放 - 不是源代码问题

iphone - 如何查看通讯录中是否添加了新联系人?

iphone - 连接信用卡读卡器

iphone - 使用 JSON 将 NSDictionary 保存到 MySQL

google-maps - 在 Google Maps v3 中,从内存中删除标记是否会自动杀死任何听众?

android - 如何在Google Maps Android上 “increase” VisibleRegion的大小

iphone - 如何在 iPhone SDK 中向单个用户发送推送通知?

ios - 如何正确清理 AVCaptureSession 和 AVCaptureVideoPreviewLayer

iphone - 为 iOS 实现推送通知(服务器端)

javascript - (React ES6) 动态添加模态触发器到 map 标记