Select annotation in Map

Hello everyone. I have the following problem. I have a view with a map in which I visualize several points (annotation point). My problem is that when I select a point, I don't get any event to check, for example, the name of the annotation point, to then carry out operations.

Tengo un View con un mapa

@IBOutlet weak var Mapa: MKMapView!

I make several queries to a database that returns a series of points (annotation points).

To see which point I select, you would have to launch, once you click on the map, one of these procedures... right?

extension DatosCercanos: MKMapViewDelegate {

func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
    print("hola")
}

func mapView(_ mapView: MKMapView, didDeselect annotation: MKAnnotation) {
    print("hola")
}

func mapView(_ mapView: MKMapView, didSelect annotation: MKAnnotation) {
    print("hola")
}

func mapView(_ mapView: MKMapView, didDeselect view:MKAnnotationView)
{
    print("hola")
  

}

As you will see, I have put several procedures to see if any of them work, but none are executed, none jump to the event of pressing an annotation point

What am I doing wrong? I don't understand why the event is not executed. Some help? Thank you.

Answered by robnotyou in 747089022

Did you remember to set your DatosCercanos object to be the Mapa's MKMapViewDelegate?

Accepted Answer

Did you remember to set your DatosCercanos object to be the Mapa's MKMapViewDelegate?

Select annotation in Map
 
 
Q