MKPointAnnotation add extra property

╄→尐↘猪︶ㄣ 提交于 2019-12-11 03:47:40

问题


Is it possible to add an extra property to MKPointAnnotation? At the moment there is coordinate, title, and subtitle.

Is it possible to add a url property which can be accessed within -(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{ }, just like I can access[annotation title];?


回答1:


Just make an MKPointAnnotation subclass.

Delete all the methods out of the .m file, and add this to your .h file:

@property (nonatomic, strong) NSURL *url;


来源:https://stackoverflow.com/questions/16737813/mkpointannotation-add-extra-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!