简体   繁体   English

迅捷注释图钉的标注气泡手势

[英]Swift Annotation Pin's Calloutbubble Gesture

I am searching an answer for adding gesture to the calloutbubble of annotation pin. 我正在寻找将手势添加到注释图钉的标注气泡的答案。

I tried different solutions, but they did not work for me. 我尝试了不同的解决方案,但它们对我没有用。

Here is the latest one: 这是最新的:

func mapView(mapView: MKMapView, didSelectAnnotationView view: MKAnnotationView{
    let rightButton = UIButton(type: UIButtonType.detailDisclosure)
    let gesture = UITapGestureRecognizer(target: self, action: #selector(callout(gesture:)))
    rightButton.addGestureRecognizer(gesture)   
    view.rightCalloutAccessoryView = rightButton
}

@objc func callout(gesture: UITapGestureRecognizer){
    print("tapped")
}

Correct delegate method 正确的委托方法

func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
    ///
}

plus

self.mapView.delegate = self

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM