I'm trying to show a callout (a small box with the title) in the pins that I show in the mapview but trying to do it directly shows me the title below the pin shown on the map.
for i in self.listaInstructor {
print("CICLO DE INSTRUCTOR")
let latitud = Double("\((i as! NSDictionary).value(forKey: "latitud")!)")!
let longitud = Double("\((i as! NSDictionary).value(forKey: "longitud")!)")!
let nombre = String("\((i as! NSDictionary).value(forKey: "nombre")!)")
let apellido = String("\((i as! NSDictionary).value(forKey: "apellido")!)")
let annotation = MKPointAnnotation()
annotation.coordinate = CLLocationCoordinate2D(latitude: latitud, longitude: longitud)
annotation.title = "\(nombre) \(apellido)"
self.mapView.addAnnotation(annotation)
}
and I'm using the following function to show the callout
func mapView(_ mapView: MKMapView, ViewFor annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation{
return nil
}
let pin = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "pin")
pin.canShowCallout = true
return pin
}