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 trialSakina Burch
1,853 Pointsanimation
Everything in my app looks great but I can not get it to animate the 60 images. It stays on the first one CB00001. Any suggestions?
6 Answers
Justin Horner
Treehouse Guest TeacherHello Sakina,
I'd like to help you with this issue. If you would, please post the relevant code to help me find potential problems.
Thanks
Rashii Henry
16,433 PointsMake sure you check your code and its seems like you've already created your array with the images. You just can't figure out why its stuck. so..
The reason its not animating and you're not getting any errors is maybe because of one of these reasons:
1) you didn't name the images properly when you created the array. 2) If you did name them all correctly you didn't call these methods immediately afterwards you initialized the array:
self.backgroundImageView.animationDuration =2.5f; self.backgroundImageView.animationRepeatCount = 1;
the first line tells how quick you want it to animate through those images. (larger the number the slower.) the second line is self explanatory as it just tells you how many time to repeat.
Rashii Henry
16,433 Pointsand also, wherever you have your button make sure you tell the imageView to start animating by saying.
[self.backgroundImageView startAnimating];
Sakina Burch
1,853 PointsThank you both for responding. I do have the start animating line of code, and the duration times work. It is just reading only the first image. Do in need the .png? added to the filename?
Justin Horner
Treehouse Guest TeacherYou're welcome! The extension is not necessary in this case. I'm looking at the code you have provided now. Thank you for posting it.
Sakina Burch
1,853 Points[self.backgroundImageView startAnimating]; is under the prediction pragma mark is this correct?
Justin Horner
Treehouse Guest TeacherYes. As long as your code looks similar like this.
#pragma mark - Prediction
- (void) makePrediction()
{
[self.backgroundImageView startAnimating];
self.predictionLabel.text = [self.crystalBall randomPrediction];
}
Where the makePrediction method is under the pragmamark.
Sakina Burch
1,853 PointsOk I moved the curly Brace up above
pragma Mark -Prediction it was inside the didRecieveMemoryWarning Braces. That was one fix but still don't see any images except the first on in the animation. It seems to be animating but no pic rotation. I am going to delete all the pics and try the steps again.
Rashii Henry
16,433 Pointswhen you press the button does the prediction show a random prediction and just not animate?
Justin Horner
Treehouse Guest TeacherAnother suggestion would be to make sure that your connection between the storyboard and backgroundImageView are properly connected. Maybe try debugging the makePrediction method and make sure that the backgroundImaveView property is not nil.
I'm pretty sure this isn't the problem since you are seeing the image change to the first image in the animation but it's worth checking at this point.
Sakina Burch
1,853 PointsSakina Burch
1,853 PointsThis is a piece of it. There are 60 images
NSURL *soundURL = [NSURL fileURLWithPath:soundPath]; AudioServicesCreateSystemSoundID(CFBridgingRetain(soundURL), &soundEffect);
.....
}
pragma mark - Prediction
} -(void) makePrediction {
Justin Horner
Treehouse Guest TeacherJustin Horner
Treehouse Guest TeacherI'm not sure if this is a copy/paste artifact or the formatting of the post but I do notice a couple of issues with the code.
If this is the case then 'pragma mark - Prediction' is inside the didReceiveMemoryWarning. Also, there's no ending bracket on the makePrediciton method. Can you confirm that your code looks like the following.
Thanks.