mapView:didSelectAnnotationView:无法正常运行。 [英] mapView: didSelectAnnotationView: not functioning properly.

查看:130
本文介绍了mapView:didSelectAnnotationView:无法正常运行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个使用内置地图视图的IOS应用。我成功地放置了自定义注释等。但是,我在按下注释时调用的委托函数有问题(mapView:didSelectAnnotationView)。

I'm building an IOS app that uses the built in map view. Im successfully placing custom annotations, etc. However, I'm having a problem with the delegate function that is called when an annotation is pressed (mapView:didSelectAnnotationView).

第一次按下注释时,该函数被正确调用。但是,如果我再次单击相同的注释,则该函数不会触发。如果我此时单击不同的注释,则函数将触发,但如果我再次单击该注释,则该函数不会触发。基本上,我永远不能连续两次点击相同的注释。委托函数将仅在第一次调用。有谁遇到过这个问题?有没有特别的地方我应该寻找这个bug?

The first time I press an annotation, the function is called properly. However, if I proceed to click the same annotation again, the function does not fire. If I click on a different annotation at this point, the function WILL fire but then if I click on THAT annotation again, the function does not fire. Basically, I can never click on the same annotation twice in a row. The delegate function will only be called the first time. Has anyone encountered this problem? Is there somewhere in particular I should look for the bug?

推荐答案

好吧,当你想到它时,你已经选择了那个注释视图。代表告诉您如果已经选择了引脚是没有意义的。

Well, when you think about it, you have already selected that annotation view. It doesn't make sense for the delegate to tell you that the pin is selected if it already is.

一个简单的解决方法是将注释设置为在委托调用中取消选择。这应该允许您再次接听电话。

A simple fix could be to set the annotation to deselected in the delegate call. This should allow you to get the call again.

[annotation setSelected:NO animated:NO];

此处列出您需要致电的方法。
https://developer.apple.com/library/ios/documentation/mapkit/reference/MKAnnotationView_Class/index.html#//apple_ref/occ/instm/MKAnnotationView/setSelected:animated

Vists here for the method you need to call. https://developer.apple.com/library/ios/documentation/mapkit/reference/MKAnnotationView_Class/index.html#//apple_ref/occ/instm/MKAnnotationView/setSelected:animated:

这篇关于mapView:didSelectAnnotationView:无法正常运行。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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