Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIImageView startAnimating: How do you get it to stop on the last image in the series?

I am using UIImageView to create a simple animation and everything works perfectly, but when I use startAnimating, the animation will run once (as I want it to) but go back to the first frame. I want the animation to stop on the last frame.

I use:

myAnimation.animationImages = myArray;
myAnimation.animationDuration = 0.7;
myAnimation.animationRepeatCount = 1;
[myAnimation startAnimating];

Could I have to use override the startAnimating method? What is the best way to fix my problem?

like image 454
Derek Avatar asked Feb 03 '26 04:02

Derek


1 Answers

Before you start animating, set the last image in the image view imageView.image = yourLastImage; and then start the animation. After the animation is complete the image view will show yourLastImage.

As for the NSTimer thing, theres no other alternative to know when the default animation has ended. So if you want to do anything after the animation completes, you have to rely on NSTimer as deanWombourne suggested.

like image 181
Swapnil Luktuke Avatar answered Feb 05 '26 20:02

Swapnil Luktuke