MapKit的点击手势 [英] Tap gesture for MapKit
本文介绍了MapKit的点击手势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前,我的地图上有几个 Annotations
.
Currently I have a map that has several Annotations
.
我有 Annotations
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView){
// Do your annotation click work
}
是否可以仅点击地图而不是 Annotation
来执行此操作,我该怎么办?
Is it possible to do this for tapping the Map only and not the Annotation
and how can I do it?
推荐答案
在 ViewWillAppear
方法中:
let gestureRecognizer = UITapGestureRecognizer(target: self, action:"triggerTouchAction:")
mapView.addGestureRecognizer(gestureRecognizer)
无论您想显示什么信息,都可以通过以下方法添加代码:
And Whatever information you want to show just add code in following method :
func triggerTouchAction(gestureReconizer: UITapGestureRecognizer) {
//Add alert to show it works
}
希望它可以帮助您解决问题.
Hope it going to help you to resolve issue.
这篇关于MapKit的点击手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文