多个注释都存在获取所选索引注释的问题 [英] multiple annotation have issue to get selected index annotation

查看:84
本文介绍了多个注释都存在获取所选索引注释的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在iphone应用程序的mapView中成功显示了多个注释,但是我也遇到了问题..在屏幕顶部,我有两个Tab Map和List. map在map中显示所有注释,并在Tableview中以列表形式显示在map中显示的数据.当我单击特定的单元格时,我会获得该单元格的所有特定细节.但是当我尝试从Tap注释中获取ID时,在比较名称后,我的数组会得到很多ID,因为我们在数组列表中拥有相同的名称,所以我该如何区分从注释标记.如何设置注释标签?

I have displayed multiple annotation successfully in mapView in my iphone application, but I have problem too .. In top of the screen I have two Tab Map and List . map display all annotation in map and list display those data in Tableview which is display in map. when I click on particular cell i get all the particular detail of that cell.but when I try to get id from Tap annotation my array getting lots of id after comparison of name because we have same name in my array list so how can I differentiate from annotation tag. How to set tag of annotations ?

推荐答案

calloutAccessoryControlTapped委托方法中,使用view.annotation访问被点击的注释.

In the calloutAccessoryControlTapped delegate method, use view.annotation to access the annotation that was tapped.

如果您有一个自定义注释类,则可以对其进行强制转换以方便地访问属性(您可能还需要先检查被点击的注释是否是您感兴趣的类的实例,如果您感兴趣,则很重要使用多个注释类):

If you have a custom annotation class, you can cast it to easily access the properties (you may also want to first check if the annotation tapped is an instance of the class you're interested in--important if you're using multiple annotation classes):

if ([view.annotation isKindOfClass:[TagMark class]]) {
    TagMark *tm = (TagMark *)view.annotation;
    NSLog(@"tm.someProperty = %@", tm.someProperty);
}

这篇关于多个注释都存在获取所选索引注释的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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