multiple annotation have issue to get selected index annotation

拜拜、爱过 提交于 2020-01-05 04:40:32

问题


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 ?


回答1:


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);
}


来源:https://stackoverflow.com/questions/7431208/multiple-annotation-have-issue-to-get-selected-index-annotation

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