简体   繁体   English

如何在MapView中检索已经叠加的MkAnnotation引脚

[英]How retrieve already diplayed MkAnnotation pin in MapView

one part of my applikation covers an MkMapview. 我的应用程序的一部分涵盖了MkMapview。 Therefore i load a list of geocode information from my server and place each tuple as a MkAnnotation pin on my map. 因此,我从我的服务器加载一个地理编码信息列表,并将每个元组作为MkAnnotation引脚放在我的地图上。 After being placed each MkAnnotation object will be released. 放置后,每个MkAnnotation对象都将被释放。 Now i want to search for a specific MkAnnotation already being placed on my map and if available popup the addtional information bubble.How do i achieve that? 现在我想搜索已放置在我的地图上的特定MkAnnotation,如果可用,则弹出附加信息bubble.How我能做到这一点吗? Thanks. 谢谢。

There is a property on your MKMapView ( from the apple docs ): MKMapView上有一个属性( 来自apple docs ):

@property (nonatomic, readonly) NSArray *annotations

It returns an array of annotations and you can search the array for what you need. 它返回一个注释数组,您可以在数组中搜索所需内容。

Hope this helps! 希望这可以帮助!

EDIT: 编辑:

Also, I just saw that you want to programmatically select an annotation... if you take a look at the selectedAnnotations property on the MKMapView class it says: 另外,我刚看到你想以编程方式选择一个注释......如果你看一下MKMapView类中的selectedAnnotations属性,它会说:

Assigning a new array to this property selects the first annotation in the array only. 为此属性分配新数组仅选择阵列中的第一个注释。

So you could pass in an Array with your annotation you want selected... I've never tried it but it would seem that it should work based on what the docs say . 因此,您可以使用您想要选择的注释传入一个数组...我从未尝试过它,但它似乎应该根据文档的说法起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM