I am loading an annotation onto my map view. The annotation displays as a pin when the map is loaded.
However, the title and subtitle do not appear on the pin automa
Starting in iOS 11, there is a new type of MKAnnotationView
called MKMarkerAnnotationView
, which can display title and subtitle without being selected. Check https://developer.apple.com/documentation/mapkit/mkmarkerannotationview
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
guard !(annotation is MKUserLocation) else {
return nil
}
if #available(iOS 11.0, *) {
let annoView = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: "HunterAnno")
annoView.canShowCallout = true
return annoView
}
let annoView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "HunterAnnoLow")
annoView.canShowCallout = true
return annoView
}