We know that UIImageView
has a very nice support for image sequence animation. We can easily create an array of UIImage objects, set the animationImages
property, configure animation duration, repeat count etc. and then just fire. But there seems to be no way to know when this animation has ended.
Say I have ten images and then I want to run an animation (repeat count = 1) with them. And when the animation is over, I want to run some other code. What is the best way to know that animation has ended?
I already understand that I can create a NSTimer
and schedule it to fire after animation duration. But you really cannot rely on timer if you need good precision.
So my question is, is there any better way to know that an UIImageView
image sequence animation has ended without using the timer?
The code is something like this
myImageView.animationImages = images; // images is a NSArray of UIImages myImageView.animationDuration = 2.0; myImageView.animationRepeatCount = 1; [myImageView startAnimating]