两次选择一个MapView注释 [英] Selecting a MapView Annotation Twice

查看:79
本文介绍了两次选择一个MapView注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iPhone应用程序具有一个包含大量位置的地图视图,用户可以从中进行选择.我希望他能够点击其中一个注释以显示其标注视图,然后再次选择它.问题是didSelectAnnotationView仅被调用一次.

My iPhone app has a mapview with a large number of locations that the user can select from. I would like him to be able to tap on one of the annotations to display its callout view, and then again to actually select it. The problem is that the didSelectAnnotationView only gets called once.

那么我如何才能检测到已选择的注释的选择?或者,如何在不隐藏标注视图的情况下取消选择注释?用户可以通过在再次选择注释之前取消选择注释来解决此问题,但这并不直观,我想避免他必须这样做.

So how can I detect the selection an already selected annotation? Alternatively, how can I deselect an annotation without hiding the callout view? The user can work round this by deselecting the annotation before he selects it again, but this is not intuitive, and I want to avoid him having to do this.

推荐答案

我刚刚找到了以下代码的解决方案:

I just found the solution with the code below:

-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
    [mapview deselectAnnotation:view.annotation animated:NO];

}

通过这种方式,选定的注释将被取消选择,您可以再次选择它.

This way the selected annotation gets deselected and you can select it once again.

这篇关于两次选择一个MapView注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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