I am making 3 simple animations that has to go in sequence. I want to use the animationDidStop, but so far only able to detect the first animation stop only, not the 2nd and 3rd.
The code:
Code:
-(void) animationDidFinished:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
int num = [finished intValue];
if ((num==1)&&([animationID isEqualTo:@"TurretAnimate1"])) {
[UIView beginAnimations: @"TurretAnimate2" context: nil];
[UIView setAnimationDuration: 0.3];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate: self];
[UIView setAnimationDidStopSelector:@selector(animationDidFinished:finished:context:)];
theturret.transform = CGAffineTransformMakeRotation(0);
[UIView commitAnimations];
accelval.text = [NSString stringWithFormat:@"%.2f", theangle];
}
if ((num==1)&&([animationID isEqualTo:@"TurretAnimate2"])) {
// do 3rd animation with ID TurretAnimate3
}
if ((num==1)&&([animationID isEqualTo:@"TurretAnimate3"])) {
// do cleanup
}
}
-(void)UpdateTurret {
[UIView beginAnimations: @"TurretAnimate1" context: nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration: 0.3];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDidStopSelector:@selector(animationDidFinished:finished:context:)];
if (theangle<0) theangle = 0;
if (theangle>PIE) theangle = PIE;
theturret.transform = CGAffineTransformMakeRotation(theangle);
[UIView commitAnimations];
}
Please note that im using 2.2.1, so it is using NSNumber, instead of BOOL for 'finished' parameter.
Thanks