MKPointAnnotation添加额外的属性 [英] MKPointAnnotation add extra property

查看:260
本文介绍了MKPointAnnotation添加额外的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以向 MKPointAnnotation 添加一个额外的属性?现在有 coordinate title subtitle



是否可以添加 url 属性,可以在 - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id< MKAnnotation>)annotation {} ,就像我可以访问 [annotation title];

解决方案

只需创建一个 MKPointAnnotation 子类。 >

删除 .m 文件中的所有方法,并将其添加到您的 .h file:

  @property(nonatomic,strong)NSURL * url; 


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];?

解决方案

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;

这篇关于MKPointAnnotation添加额外的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆