0

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")
}
Ahmet Aziz Beşli
  • 1,280
  • 3
  • 19
  • 38

1 Answers1

0

Correct delegate method

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

plus

self.mapView.delegate = self
Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87