Hi all, I have an odd question here. I have two animations set up for a simple page flip. I then have a button that randomly generates a 1 or a 0. If the number is 0 then it performs one animation, if its 1 it performs another.
The issues I'm seeing is that this all runs fine on the simulator, but on the device it doesn't perform the animation if the random number is 0.
Any clues?
-(IBAction)pageTurn:(id)sender {
int randomNumber = arc4random() %2;
NSLog(@"randomNumber = %d", randomNumber);
if (randomNumber == 0) {
[self turnPageForward];
} else {
[self turnPageBackward];
}
}
-(void)turnPageForward {
NSArray *myImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"PageTurnOne.png"],
[UIImage imageNamed:@"PageTurnTwo.png"],
[UIImage imageNamed:@"PageTurnThree.png"],
[UIImage imageNamed:@"PageTurnFour.png"],
[UIImage imageNamed:@"PageTurnFive.png"],
[UIImage imageNamed:@"PageTurnSix.png"],
[UIImage imageNamed:@"PageTurnSeven.png"],
[UIImage imageNamed:@"PageTurnEight.png"],
[UIImage imageNamed:@"PageTurnNine.png"],
nil];
UIImageView *myAnimatedView = [UIImageView alloc];
[myAnimatedView initWithFrame:CGRectMake(0, 0, 320, 480)];
myAnimatedView.animationImages = myImages;
myAnimatedView.animationDuration = .5; // seconds
myAnimatedView.animationRepeatCount = 1; // 0 = loops forever
[myAnimatedView startAnimating];
[self.view addSubview:myAnimatedView];
[myAnimatedView release];
}
-(void)turnPageBackward {
NSArray *myImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"PageTurnNine.png"],
[UIImage imageNamed:@"PageTurnEight.png"],
[UIImage imageNamed:@"PageTurnSeven.png"],
[UIImage imageNamed:@"PageTurnSix.png"],
[UIImage imageNamed:@"PageTurnFive.png"],
[UIImage imageNamed:@"PageTurnFour.png"],
[UIImage imageNamed:@"PageTurnThree.png"],
[UIImage imageNamed:@"PageTurnTwo.png"],
[UIImage imageNamed:@"PageTurnOne.png"],
nil];
UIImageView *myAnimatedView = [UIImageView alloc];
[myAnimatedView initWithFrame:CGRectMake(0, 0, 320, 480)];
myAnimatedView.animationImages = myImages;
myAnimatedView.animationDuration = .5; // seconds
myAnimatedView.animationRepeatCount = 1; // 0 = loops forever
[myAnimatedView startAnimating];
[self.view addSubview:myAnimatedView];
[myAnimatedView release];
}