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

iOS Build a Simple iPhone App (iOS7) Animating and Intercepting Events Image Based Animation

David McLaughlin
David McLaughlin
3,615 Points

Instruct your 'imageView' to start running the animation.

I can't figure out how to do this. I don't know where to put [self.imageView.startAnimation];

The error message is "Bummer! Remember to call the appropriate method on the 'imageView'."

This is my code so far:

import "THViewController.h"

@implementation THViewController

  • (void)viewDidLoad { [super viewDidLoad];

    // backgroundImage is a local variable UIImage *backgroundImage = [UIImage imageNamed:@"background"]; // imageView is a property self.imageView = [[UIImageView alloc] initWithImage:backgroundImage];

    // Add your code below! // Remember 'imageView' is a property // so refer to it as 'self.imageView' self.imageView.animationImages = [[NSArray alloc] initWithObjects: [UIImage imageNamed: @"01"],[UIImage imageNamed: @"02"],[UIImage imageNamed: @"03"],nil];

self.imageView.animationDuration=5;

[self.imageView.startAnimation]; }

@end

3 Answers

Stone Preston
Stone Preston
42,016 Points

the method is[self.imageView startAnimation] not [self.imageView.startAnimation]. Fix that and see if it works. You also may or may not need to set the duration of the animation, if the challenge asks for you to set the duration include it but if it doesnt I would remove that line.

David McLaughlin
David McLaughlin
3,615 Points

Thanks Stone, that was a good catch. I also needed to change "startAnimation" to "startAnimating".

Thanks again. I can finally check off this exercise.

Stone Preston
Stone Preston
42,016 Points

glad you got it figured out

Ihosvany Diaz
Ihosvany Diaz
2,946 Points

Solution

self.imageView.animationImages = [[NSArray alloc] initWithObjects : [UIImage imageNamed: @"01"], [UIImage imageNamed: @"02"], [UIImage imageNamed: @"03"], nil]; self.imageView.animationDuration = 5; [self.imageView startAnimating];