Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

iphone - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...