J'ai personnalisé mon callOutView
, en créant un AnnotationView
theGreatAnnotationView
, mais je veux conserver la broche d'annotation standard sur la carte. Dans ce code, j'utilise une image d'annotation personnalisée view?.image = annotation.image
mais lorsque la ligne est supprimée, il n'y a pas d'annotation sur ma carte. Pouvez-vous m'aider à résoudre ce problème?Comment utiliser le symbole MKAnnotation standard avec un MKAnnotationView fait sur mesure
func mapView(_ surroundingMapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
var annoView: MKAnnotationView?
if annotation.isKind(of: MKUserLocation.self) {
return nil
}
var view = surroundingMapView.dequeueReusableAnnotationView(withIdentifier: "imageAnnotation")
if view == nil {
view = theGreatAnnotationView(annotation: annotation, reuseIdentifier: "imageAnnotation")
reuseIdentifier: "imageAnnotation")
view!.canShowCallout = false
}
let annotation = annotation as! Artwork
view?.image = annotation.image
view?.annotation = annotation
return view
}
Si vous voulez une broche standard sur votre carte plutôt qu'une 'image', vous devez utiliser' MKPinAnnotationView'. – Rob