通过 iPhone 中的代码显示地图标注 [英] show map callout through code in iPhone

查看:24
本文介绍了通过 iPhone 中的代码显示地图标注的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了几件事,但无法解决.

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

我在地图上有 10 个自定义注释,具体取决于可见区域.

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

现在我有 2 个按钮下一个和上一个.单击必须显示注释的标注.

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

即,如果我单击下一个按钮,则会出现注释 1 的标注,当我再次单击下一步时,第一个标注将隐藏,第二个标注将出现.

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.

我试过了

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

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

但是主要的问题是如何得到这里的注解??

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

我尝试了 NSArray* selectedAnnotations=self.mapview.annotations 来获取注释数组

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

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

但没有运气:(

还有其他方法可以解决我的问题.??

Any other way to solve my issue.??

推荐答案

它可能对您有所帮助.

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

这篇关于通过 iPhone 中的代码显示地图标注的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆