show map callout through code in iPhone

守給你的承諾、 提交于 2019-12-11 02:33:03

问题


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.

i.e 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.??


回答1:


it may help you.

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


来源:https://stackoverflow.com/questions/6664125/show-map-callout-through-code-in-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!