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
Ganesh Gunaratnam
1,007 PointsAnimation Not working
Hi I am not sure what I am doing wrong here.
@synthesize imageView;
- (void)viewDidLoad
{ [super viewDidLoad];
UIImage *image = [UIImage imageNamed:@"background.png"];
self.imageView = [[UIImageView alloc] initWithImage: image];
[self.view insertSubview:self.imageView atIndex:0] ;
self.imageView.animationImages = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"cball00001"],
[UIImage imageNamed:@"cball00002"],
[UIImage imageNamed:@"cball00003"],
[UIImage imageNamed:@"cball00004"],
[UIImage imageNamed:@"cball00005"],
[UIImage imageNamed:@"cball00006"],
[UIImage imageNamed:@"cball00007"],
[UIImage imageNamed:@"cball00008"],
[UIImage imageNamed:@"cball00009"],
[UIImage imageNamed:@"cball00010"],
[UIImage imageNamed:@"cball00011"],
[UIImage imageNamed:@"cball00012"],
[UIImage imageNamed:@"cball00013"],
[UIImage imageNamed:@"cball00014"],
[UIImage imageNamed:@"cball00015"],
[UIImage imageNamed:@"cball00016"],
[UIImage imageNamed:@"cball00017"],
[UIImage imageNamed:@"cball00018"],
[UIImage imageNamed:@"cball00019"],
[UIImage imageNamed:@"cball00020"],
[UIImage imageNamed:@"cball00021"],
[UIImage imageNamed:@"cball00022"],
[UIImage imageNamed:@"cball00023"],
[UIImage imageNamed:@"cball00024"], nil];
self.imageView.animationDuration = 1.0;
self.imageView.animationRepeatCount = 1;
- (void) makePrediction { NSUInteger index = arc4random_uniform(self.predicitonArray.count); self.predictionLabel.text = [self.predicitonArray objectAtIndex:index]; [self.imageView startAnimating ];
}
Any help will be much appreciated. Thanks
2 Answers
Mike Bronner
16,395 PointsHere is the code i have for this:
[super viewDidLoad];
self.imageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"background"]];
[self.view insertSubview: imageView atIndex:0];
self.imageView.animationImages = [[NSArray alloc] initWithObjects: [UIImage imageNamed: @"cball00001"],
[UIImage imageNamed: @"cball00002"],
[UIImage imageNamed: @"cball00003"],
[UIImage imageNamed: @"cball00004"],
[UIImage imageNamed: @"cball00005"],
[UIImage imageNamed: @"cball00006"],
[UIImage imageNamed: @"cball00007"],
[UIImage imageNamed: @"cball00008"],
[UIImage imageNamed: @"cball00009"],
[UIImage imageNamed: @"cball00010"],
[UIImage imageNamed: @"cball00011"],
[UIImage imageNamed: @"cball00012"],
[UIImage imageNamed: @"cball00013"],
[UIImage imageNamed: @"cball00014"],
[UIImage imageNamed: @"cball00015"],
[UIImage imageNamed: @"cball00016"],
[UIImage imageNamed: @"cball00017"],
[UIImage imageNamed: @"cball00018"],
[UIImage imageNamed: @"cball00019"],
[UIImage imageNamed: @"cball00020"],
[UIImage imageNamed: @"cball00021"],
[UIImage imageNamed: @"cball00022"],
[UIImage imageNamed: @"cball00023"],
[UIImage imageNamed: @"cball00024"],
nil];
self.imageView.animationDuration = 1;
self.imageView.animationRepeatCount = 1;
Looks pretty much the same -- could the error be somewhere else?
Ganesh Gunaratnam
1,007 PointsFound the issue I had the background image on both storyboard and viewDidLoad method. That was the issue once I removed it from the Story board it started to work.
Ganesh Gunaratnam
1,007 PointsGanesh Gunaratnam
1,007 PointsThe error could be some where else. But I am not sure where else. Any one else?