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 trialStuart Forrest
4,178 PointsMy background wont animate :-(
I've checked my code and it appears to be the same but no animation.
3 Answers
Stuart Forrest
4,178 PointsI knew it would be something stupid....Missing 0 in image name...Sorry to have troubled you...
Stuart
Patrick Serrano
13,834 PointsPlease share your code with us so we can take a look. Also are you getting any complier warning in Xcode?
Stuart Forrest
4,178 PointsThanks for helping Patrick, probably something really simple I am missing.
ViewController.h // // bfViewController.h // Crystal Ball // // Created by Stuart Forrest on 5/23/14. // Copyright (c) 2014 Stareagle. All rights reserved. //
import <UIKit/UIKit.h>
@class bfCrystallBall;
@interface bfViewController : UIViewController
@property (strong, nonatomic) IBOutlet UILabel *labelPrediction; @property (strong, nonatomic) bfCrystallBall *crystalBall;
@property (strong, nonatomic) IBOutlet UIImageView *backgroundImageView;
- (void) makePrediction;
@end
ViewController.m // // bfViewController.m // Crystal Ball // // Created by Stuart Forrest on 5/23/14. // Copyright (c) 2014 Stareagle. All rights reserved. //
import "bfViewController.h"
import "bfCrystallBall.h"
@interface bfViewController ()
@end
@implementation bfViewController
(void)viewDidLoad{ [super viewDidLoad]; // Do any addit ional setup after loading the view, typically from a nib. self.crystalBall = [[bfCrystallBall alloc]init]; self.backgroundImageView.animationImages = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"CB0001"], [UIImage imageNamed:@"CB0002"], [UIImage imageNamed:@"CB0003"], [UIImage imageNamed:@"CB0004"], [UIImage imageNamed:@"CB0005"], [UIImage imageNamed:@"CB0006"], [UIImage imageNamed:@"CB0007"], [UIImage imageNamed:@"CB0008"], [UIImage imageNamed:@"CB0009"], [UIImage imageNamed:@"CB0010"], [UIImage imageNamed:@"CB0011"], [UIImage imageNamed:@"CB0012"], [UIImage imageNamed:@"CB0013"], [UIImage imageNamed:@"CB0014"], [UIImage imageNamed:@"CB0015"], [UIImage imageNamed:@"CB0016"], [UIImage imageNamed:@"CB0017"], [UIImage imageNamed:@"CB0018"], [UIImage imageNamed:@"CB0019"], [UIImage imageNamed:@"CB0020"], [UIImage imageNamed:@"CB0021"], [UIImage imageNamed:@"CB0022"], [UIImage imageNamed:@"CB0023"], [UIImage imageNamed:@"CB0024"], [UIImage imageNamed:@"CB0025"], [UIImage imageNamed:@"CB0026"], [UIImage imageNamed:@"CB0027"], [UIImage imageNamed:@"CB0028"], [UIImage imageNamed:@"CB0029"], [UIImage imageNamed:@"CB0030"], [UIImage imageNamed:@"CB0031"], [UIImage imageNamed:@"CB0032"], [UIImage imageNamed:@"CB0033"], [UIImage imageNamed:@"CB0034"], [UIImage imageNamed:@"CB0035"], [UIImage imageNamed:@"CB0036"], [UIImage imageNamed:@"CB0037"], [UIImage imageNamed:@"CB0038"], [UIImage imageNamed:@"CB0039"], [UIImage imageNamed:@"CB0040"], [UIImage imageNamed:@"CB0041"], [UIImage imageNamed:@"CB0042"], [UIImage imageNamed:@"CB0043"], [UIImage imageNamed:@"CB0044"], [UIImage imageNamed:@"CB0045"], [UIImage imageNamed:@"CB0046"], [UIImage imageNamed:@"CB0047"], [UIImage imageNamed:@"CB0048"], [UIImage imageNamed:@"CB0049"], [UIImage imageNamed:@"CB0050"], [UIImage imageNamed:@"CB0051"], [UIImage imageNamed:@"CB0052"], [UIImage imageNamed:@"CB0053"], [UIImage imageNamed:@"CB0054"], [UIImage imageNamed:@"CB0055"], [UIImage imageNamed:@"CB0056"], [UIImage imageNamed:@"CB0057"], [UIImage imageNamed:@"CB0058"], [UIImage imageNamed:@"CB0059"], [UIImage imageNamed:@"CB0060"],nil]; self.backgroundImageView.animationDuration = 2.5f; self.backgroundImageView.animationRepeatCount = 1; }
(void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }
pragma mark - Prediction
- (void) makePrediction{ [self.backgroundImageView startAnimating]; self.labelPrediction.text = [self.crystalBall randomPrediction]; self.labelPrediction.textColor = [UIColor purpleColor]; }
pragma mark - Motion Events
(void) motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{ self.labelPrediction.text = nil; NSLog(@"Motion Began"); }
(void) motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event{ if (motion == UIEventSubtypeMotionShake) { [self makePrediction]; } NSLog(@"Motion ended"); }
(void) motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event{ NSLog(@"Motion Cancelled"); }
pragma mark - Touch Events
(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ self.labelPrediction.text = nil; }
(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ [self makePrediction]; }
(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
} @end
Kai Aldag
Courses Plus Student 13,560 PointsKai Aldag
Courses Plus Student 13,560 Pointsplease paste in your code