简体   繁体   中英

How retrieve already diplayed MkAnnotation pin in MapView

one part of my applikation covers an MkMapview. Therefore i load a list of geocode information from my server and place each tuple as a MkAnnotation pin on my map. After being placed each MkAnnotation object will be released. 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? Thanks.

There is a property on your MKMapView ( from the 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:

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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