Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

Jon Reese
Jon Reese
2,335 Points

Instruct 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
Ihosvany Diaz
2,946 Points

Here 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
Stone Preston
42,016 Points

there is a special method you need to call on your imageView to tell it to (hint hint) start animating.

Jon Reese
Jon Reese
2,335 Points

Yeah, that's what I thought this was - [self.imageView startAnimating]; I'm pretty confused honestly

Stone Preston
Stone Preston
42,016 Points

ah 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