Updating MKAnnotationView.image does not properly update the callout bubble's x-position

Originator:johnhammerlund
Number:rdar://47615802 Date Originated:1/28/2019
Status:Open Resolved:
Product:iOS SDK Product Version:12.1.2
Classification:Bug Reproducible:Always
 
Area:
MapKit

Summary:
After an MKAnnotationView has been created & displayed, then updating its image to one with a different horizontal size than the original image does not modify the x-position of the callout bubble. In other words, updating to a larger image in `mapView(_:didSelect:)` will present the callout at the correct y-position (at the top of the grown annotation view), but the x-position will fall short of the center. A workaround to this would be to modify the `calloutOffset` to the difference in distance between the old & new image centerX. This is obviously not preferred as a `calloutOffset` of `CGPoint.zero` should imply that the callout is horizontally centered above the annotation view.

Steps to Reproduce:
1. Set up an MKMapView with a list of annotations, each with a non-nil `title`
2. Within the delegate implementor, ensure that each `MKAnnotationView` has:
- `canShowCallout` set to `true`
- `image` set to a provided `UIImage`
3. Within `mapView(_:didSelect:)`, update the annotation view with a horizontally larger `UIImage` than the original
4. Within `mapView(_:didDeselect:)`, update the annotation view with the original image
5. Run the project and tap on any annotation view

Expected Results:
Callout bubble animates in (or not) to the correct position above the annotation view

Actual Results:
Callout bubble animates in to the correct y-position, but at the incorrect x-position of originalImage.width/2

Version/Build:
iOS 12.1.2, Xcode 10.1, Swift 4.2

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!