I have two animations in a custom UIView, anim1 and anim2. Anim1 sets its delegate to self and there is an animationDidStop method in my class which triggers Anim2. If I want something else to occur when Anim2 finishes, how do I do this? Can I specify a delegate method with a different name?
UPDATE
I declare two animations as iVars:
CABasicAnimation *topFlip;
CABasicAnimation *bottomFlip;
I build each animation and set delgate to self e.g.
- (CABasicAnimation *)bottomCharFlap: (CALayer *)charLayer
{
bottomFlip = [CABasicAnimation animationWithKeyPath:@"transform"];
charLayer.transform = CATransform3DMakeRotation(DegreesToRadians(0), 1, 0, 0); //set to end pos before animation
bottomFlip.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(DegreesToRadians(-360), 1, 0, 0)];
bottomFlip.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(DegreesToRadians(-270), 1, 0, 0)];
bottomFlip.autoreverses = NO;
bottomFlip.duration = 0.5f;
bottomFlip.repeatCount = 1;
bottomFlip.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut];
bottomFlip.delegate = self;
bottomFlip.removedOnCompletion = FALSE;
return bottomFlip;
}
I then try and find bottomFlip in animationdidStop:
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
if (theAnimation == bottomFlip) {
NSLog(@"Bottom Animation is: %@", bottomFlip);
}
NSLog(@"Animation %@ stopped",theAnimation);
[bottomHalfCharLayerFront addAnimation:[self bottomCharFlap:bottomHalfCharLayerFront] forKey:@"bottomCharAnim"];
bottomHalfCharLayerFront.hidden = NO;
topHalfCharLayerFront.hidden = YES;
//insert the next one???
}
"Animation stopped" is logged but nothing else i.e. it doesn't seem to recognise the bottomFlip iVar