【问题标题】:Tap gesture for MapKitMapKit 的点击手势
【发布时间】:2017-04-25 20:22:07
【问题描述】:
目前我的地图有几个Annotations。
对于Annotations我有
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView){
// Do your annotation click work
}
是否可以只点击地图而不是Annotation,我该怎么做?
【问题讨论】:
标签:
ios
swift
swift3
mapkit
core-location
【解决方案1】:
在ViewWillAppear 方法中:
let gestureRecognizer = UITapGestureRecognizer(target: self, action:"triggerTouchAction:")
mapView.addGestureRecognizer(gestureRecognizer)
无论您想显示什么信息,只需在以下方法中添加代码:
func triggerTouchAction(gestureReconizer: UITapGestureRecognizer) {
//Add alert to show it works
}
希望它能帮助您解决问题。