Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Matthew Waller
1,698 PointsStopping on the last image after a startAnimating
Hi, I just finished the Crystal Ball app, and I was wondering if there was a way to make the app display the last image in the animation array rather than go back and display the first image.
I'm working on another app, and that ability would be really helpful. Anyone have any ideas?
2 Answers
Kai Aldag
Courses Plus Student 13,560 Pointsmaybe if in the action method after the animation is displayed you could add a line with a method to display you're image. let me know if it works, Kai.
Matthew Waller
1,698 PointsHa! I got it. It took a while, but essentially what you suggested was right. I put self.imageView.image =[self.imageView.animationImages lastObject] in the getFortune method, and it works. Code looks like this:
-
(void) getFortune { NSUInteger index = arc4random_uniform(self.fortuneArray.count);
self.fortuneLabel.text = [self.fortuneArray objectAtIndex:index]; self.imageView.image = [self.imageView.animationImages lastObject]; [self.imageView startAnimating];
[UIView animateWithDuration:0.0 delay:1.0 options: UIViewAnimationOptionTransitionNone animations:^ {self.fortuneLabel.alpha = 1.0; } completion: nil]; }
Kai Aldag
Courses Plus Student 13,560 Pointsgreat, happy to help. by the way a top comment helps a lot.
Matthew Waller
1,698 PointsMatthew Waller
1,698 PointsHey, I think I got it. I posted the answer!