MapKit and Core Location · Challenge: Customize the Annotation |

This is a companion discussion topic for the original entry at

Nice course! How can we auto scale the detailCalloutAccessoryView and the image it contains?

After doing the challenge to add the detailCalloutAccessoryView, some of the images did not fit and were scaled to have a different aspect ratio.

I set the contentMode of the imageView as below and this scaled the image nicely, but the annotationView still was too big and needs to be scaled to match the imageView.

  imageView.contentMode = .scaleAspectFit
  annotationView?.detailCalloutAccessoryView = imageView

I haven’t tried but I believe you can call core graphics calls with your view and thus do the scaling yourself. Granted, it takes a little bit of code but we have a complete course on it, if you are interested.