如何在 MKPinAnnotation 中存储与引脚相关的信息
实际上,我已经从网络服务中检索了很多有关服务站的信息,它们在这里,我为每个站显示了一个引脚注释,以使用 UIButtonTypeDetailDisclosure
将其显示在地图上,现在我想为每个引脚存储一些附加信息,例如:
float lng = [[stationEnCours objectForKey:@"ssiphone_longitude"] floatValue];//that's how i retrieve it from web-service
float lat = [[stationEnCours objectForKey:@"ssiphone_latitude"] floatValue];//that's how i retrieve it from web-service
出于我的目的,我使用委托的这种众所周知的方法:
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"calloutAccessoryControlTapped");
//how to do to store additional informations
}
但我有点受阻,我如何存储与每个引脚相关的附加信息,请帮忙,任何建议,示例代码,教程将不胜感激:)))))提前谢谢
actually, i have retrieved a lot of informations about service stations from web-service, they are here, i displayed for each Station a pin annotation to show it on the Map with a UIButtonTypeDetailDisclosure
, now i want to store for each pin some additional informations like :
float lng = [[stationEnCours objectForKey:@"ssiphone_longitude"] floatValue];//that's how i retrieve it from web-service
float lat = [[stationEnCours objectForKey:@"ssiphone_latitude"] floatValue];//that's how i retrieve it from web-service
for my purpose, i use this well known method of the delegate :
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"calloutAccessoryControlTapped");
//how to do to store additional informations
}
but i am some kind blocked, how can i store additional informations related to each pin, help please, any suggestions, sample code, tutorials will be appreciated :))))) thx in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,在 MyLocation.h(实现 MKAnnotation 的类)中声明所有属性。创建注释时,在调用 addAnnotation 之前,请设置属性。
在 calloutAccessoryControlTapped 中,获取如下属性(示例使用上一个问题中定义的 MyLocation 中的属性):
Yes, declare all your properties in MyLocation.h (the class that implements MKAnnotation). When creating annotations and before calling
addAnnotation
, set the properties.In
calloutAccessoryControlTapped
, get the properties like this (example uses properties in MyLocation defined in your previous question):