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 trialJon Reese
2,335 PointsInstruct your 'imageView' to start running the animation. Not Working.
#import "THViewController.h"
@implementation THViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.imageView startAnimating];
// backgroundImage is a local variable
UIImage *backgroundImage = [UIImage imageNamed:@"background"];
// imageView is a property
self.imageView = [[UIImageView alloc] initWithImage:backgroundImage];
self.imageView.animationImages = [[NSArray alloc] initWithObjects:
[UIImage imageNamed: @"01.png"],
[UIImage imageNamed: @"02.png"],
[UIImage imageNamed: @"03.png"], nil];
self.imageView.animationDuration = 5.0f;
}
@end
"Bummer! You didn't call the specific method that instructs an UIImageView to start running the animation."
3 Answers
Ihosvany Diaz
2,946 PointsHere is the solution:
self.imageView.animationImages = [[NSArray alloc] initWithObjects : [UIImage imageNamed: @"01"], [UIImage imageNamed: @"02"], [UIImage imageNamed: @"03"], nil]; self.imageView.animationDuration = 5; [self.imageView startAnimating];
Stone Preston
42,016 Pointsthere is a special method you need to call on your imageView to tell it to (hint hint) start animating.
Jon Reese
2,335 PointsYeah, that's what I thought this was -
[self.imageView startAnimating];
I'm pretty confused honestly
Stone Preston
42,016 Pointsah yes. sorry I didnt see it there. that needs to go after you set the animation images and duration. you called it way up at the very beginning of viewDidLoad before you set any of the animation properties. try putting it after you set the duration