MKAnnotation - 添加 url
我正在通过 mayurbirari 的示例代码生成一个 Mapkit 视图,我想向弹出窗口添加一个 url。我试图理解苹果对子类的引用,但说实话,它只是没有实现。
我需要创建一个子类,可以添加额外的变量,因为 MKANNOTATION 是核心文件并且无法更改 - 那么我该怎么做?我对如何设置它感到困惑。
代码可以在这里找到 --> http://mayurbirari.wordpress.com/ 2011/02/07/how-to-access-mkmapkit-in-iphone/
如果有人可以向我展示添加了 URL 的子类示例,它可能会被吸收,但我的所有示例我发现似乎过于复杂。
I'm working through mayurbirari's sample code to generate a mapkit view, I want to add a url to the popup. I've tried to understand the apple reference to subclass but TBH it just isnt going it.
I need to create a subclass that can have additional variable added to it as MKANNOTATION is core file and cannot be changed - therefore how do I do it?? I'm confused about how to set it up.
the code can be found here --> http://mayurbirari.wordpress.com/2011/02/07/how-to-access-mkmapkit-in-iphone/
if someone could show me the example of the subclass with URL added to it, it would probably sink in, but all the examples I've found seem to be over complicated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MKAnnotation 是您必须在自己的类中采用的协议——无论您使用哪个类来表示注释对象。这通常是属于数据模型一部分的类。例如,您可能有一个 Person 类并希望在地图上显示 Person 的实例。您将亲自采用 MKAnnotation。为此,使用属性很容易:
然后在您的类中实现 MKAnnotation 的方法:
现在您可以将 Person 的实例作为注释添加到地图中。
MKAnnotation is a protocol that you have to adopt in your own class -- whichever class you're using to represent an annotation object. This is often a class that's part of your data model. For example, you might have a Person class and want to show instances of Person on a map. You'd adopt MKAnnotation in Person. It's easy to use properties for this:
And then implement the methods from MKAnnotation in your class:
Now you can add instances of Person to the map as annotations.