Scrungepipes
Scrungepipes

Reputation: 37581

How to animate the appearance of an MKAnnotationView when it gets re-used

I have a class derived from MKAnnotationView and am fading in its appearance within its init using UIView:animateWithDuration for its alpha.

This works the first time the annotation is added to the map, however if the annotation is removed and then re-added then the init method is not getting called no doubt due to the fact the annotation view has been cached.

How can I fade in the appearance of the annotation view when it gets re-added?

Note: it won't be possible to add the animation to didAddAnnotationViews: because if an annotation view gets added with co-ordinates that are currently off the viewable map region then didAddAnnotationView: does not get called in this situation.

Upvotes: 2

Views: 397

Answers (1)

David Berry
David Berry

Reputation: 41226

Override didMoveToSuperview and do it there? Or maybe do it in the delegate method `mapView:viewForAnnotation:

Upvotes: 1

Related Questions