1

I have an MKMapView to which I add MKAnnotations. When they are displayed on the map, they use an MKAnnotationView with an (UIImage *)image property for custom annotation views.
If I now create an animated UIImage with the +(UIImage *)animatedImageNamed:(NSString *)name duration:(NSTimeInterval)duration method and assign it to the image property of the MKAnnotationView, the displayed annotation view is not animated.
I cannot find anything in the docs that forbids to assign an animated UIImage to this image property, nor that it does no animation.
Sorry, there is not much code to show: Just setup the annotation view, and assign to its image property an animated image: MKAnnotationView *customAnnotationView is allocated and initialized with initWithAnnotation:reuseIdentifier:
Then customAnnotationView.image = [UIImage animatedImageNamed:name duration:duration];

Is there anything I missed or just a missing hint in the docs or do I something wrong?

Reinhard Männer
  • 14,022
  • 5
  • 54
  • 116
  • Seems to be a limitation of the MKAnnotationView. Unless you can find an easier solution, you could create a custom annotation view that does the animation manually. The answer to [this question](http://stackoverflow.com/questions/4324744/ipad-mapkit-change-title-of-current-location) gives an example of something similar (it "animates" pin color instead of the image though). –  Jul 03 '13 at 03:19
  • @Anna Karenina: Thanks for your hint, but I have implemented the animation in code earlier when I was not yet aware of the animated UIImages. I now thought it would be so much easier just to take a standard animated image, but this seems not to be possible. – Reinhard Männer Jul 03 '13 at 05:03
  • 1
    I just submitted a bug report to Apple. – Reinhard Männer Jul 03 '13 at 05:35

1 Answers1

1

Well, a friend gave me a tip for a workaround:
Make a UIImageView of the animated image, and embed it as a subview into another not-animated container UIView, and use this not-animated container view as the image of the MKAnnotationView.
In this case, the annotation view shows the animated image.

Reinhard Männer
  • 14,022
  • 5
  • 54
  • 116