简体   繁体   中英

show map callout through code in iPhone

I have tried several things but am unable to solve it out.

I have 10 custom annotations on the map depending upon the area visible.

Now I have 2 buttons next and previous. Clicking on which the callout of annotation must get displayed.

ie if i click on next buton then callout of annotation 1 will appear and when i click next again then the callout of first will hide and callout of second will appear.

I have tried out

[self.mapView selectAnnotation:self.nextSelectedAnnotationView.annotation animated:YES]

and

[self.mapView deselectAnnotation:self.selectedAnnotationView.annotation animated:YES];

But the main problem is how to get the annotation here??

I have tried NSArray* selectedAnnotations=self.mapview.annotations to get the annotations array

id annotationView =[selectedAnnotations objectAtIndex:i];
[self.mapView selectAnnotation:annotationView animated:YES];

But no luck:(

Any other way to solve my issue.??

it may help you.

 NSArray *selectedAnnotations = mapView.selectedAnnotations;
for(id annotationView in selectedAnnotations) {
    [mapView deselectAnnotation:[annotationView annotation] animated:NO];
}

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