[英]When a annotation is clicked how can I pass data to its view controller?
When an MKAnnotation is clicked I need to call a function in its view controller, and pass it two NSStrings contained in the annotation. 单击MKAnnotation时,我需要在其视图控制器中调用一个函数,并将其包含在注释中的两个NSString传递给它。 How can I achieve this?
我该如何实现?
Just assign your view controller as the map view's delegate
and implement 只需将您的视图控制器分配为地图视图的
delegate
并实现
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
MKAnnotationView
has an annotation
property that you can use to get your strings. MKAnnotationView
具有一个annotation
属性,可用于获取字符串。
Probably the annotations are some kind of buttons? 注释可能是某种按钮吗? In this case, they are the sender of the action -> A reference to the clicked annotation is passed as argument to the called function!
在这种情况下,它们是动作的发送者->对单击的批注的引用将作为参数传递给被调用的函数!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.