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 Property Based Animation

Jacob McLaws
Jacob McLaws
1,497 Points

Help! Animating alpha fade isn't working

I've been debugging for a couple hours and can't seem to figure this one out. Any clues as to why my app doesn't do what the one in the video does fading the prediction text in and out?

Below is the link to the code. Thanks!

https://www.dropbox.com/sh/qqd61pfhaiujlw6/AABQK-xZRVy2CAUkqN417DrMa?dl=0

1 Answer

Hey there Jacob,

I just looked through your code, you just forgot to call the self.predictionLabel.alpha under the touchesBegan method in your JMViewController.m. You added it for the Motion Controls (Shake), but not the Touch Controls.

Without fixing your code, open your iOS simulator and go to Hardware > Shake Event (ctrl + cmd + Z on Mac) and you'll see it works. Then, just add the following line of code so it can also work when you click(touch) the screen :

#pragma mark Touch Controls

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    self.predictionLabel.text = nil;
    self.predictionLabel.alpha = 0.0f;  // Add this line of code
}