无法两次选择MKViewAnnotation? [英] Can't select MKViewAnnotation twice?

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

问题描述

我在地图上放置了大头针,当我点击它们时,我将其称为didSelect.该功能仅在第一次敲击该引脚时被调用,此后,除非再次选择另一个引脚然后再次点击它,否则不会在同一引脚上再次调用该函数.

I've got pins placed on a map and when I tap on them I'm calling the didSelect. The function only gets called the first time the pin is tapped, and after that it's not called on that same pin again unless I select another pin and then come back and tap it.

在我看来,这是选定的引脚,而didSelect只能在未选定的引脚中调用,所以当我点击另一个引脚时,它将取消选择第一个引脚,使其再次可点击.

What that sounds like to me is the pin is being selected, and didSelect can only be called in unselected pins, so when I go tap on another pin it's deselecting the first pin and making it tappable again.

func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
    view.isSelected = false
}

我不明白上面的代码为什么不起作用.

I don't understand why the above code does not work.

如何允许连续多次点击我的注释?

How can I allow my annotations be tapped more than one time in a row?

推荐答案

尝试使用此方法deselectAnnotation

func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
     //do what you need here
     mapView.deselectAnnotation(view.annotation, animated: true)
}

希望这会有所帮助

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

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