检测更改所选注释或取消选择的点击
Detecting the tap which changes the selected annotation or deselects it
我基本上是在尝试检测注释何时被取消选择。因此,当您点击另一个注释并更改当前选定的注释时,或者当您仅点击地图时它会取消选择它。
为此有一个委托方法。只需确保将地图视图的 delegate
属性 设置为包含视图控制器即可。
optional func mapView(_ mapView: MKMapView, didDeselect view:
MKAnnotationView)
这篇link可能对您有帮助:https://developer.apple.com/documentation/mapkit/mkmapviewdelegate
我基本上是在尝试检测注释何时被取消选择。因此,当您点击另一个注释并更改当前选定的注释时,或者当您仅点击地图时它会取消选择它。
为此有一个委托方法。只需确保将地图视图的 delegate
属性 设置为包含视图控制器即可。
optional func mapView(_ mapView: MKMapView, didDeselect view:
MKAnnotationView)
这篇link可能对您有帮助:https://developer.apple.com/documentation/mapkit/mkmapviewdelegate