2012-08-27 26 views
1

我已经分组4 CABasicAnimationCAAnimationGroup。但问题是,CAAnimation代表在CAAnimationGroup

-(void) animationDidStop:(CAAnimation *)anim finished:(BOOL)flag 

不会为每个动画调用。

CABasicAnimation *anim1;//code of anim1 
anim1.deleagte=self; 
CABasicAnimation *anim2://code of anim2 
anim2.deleagte=self; 
CABasicAnimation *anim3;//code of anim3 
anim3.deleagte=self; 
CABasicAnimation *anim4://code of anim4 
anim4.deleagte=self; 

CAAnimationGroup *animGrp;//code of animGrp 
animGrp.delegate=self; 
[imageView.layer addAnimation:animGrp forKey:@""]; 

我做错了什么或有不同的方法。

我的目标是改变每个动画的UIIImageView的位置。

因此,当anim1结束时,我想更改图像,但我没有收到animationDidStop委托。

回答

3

文档状态

`CAAnimationGroup` allows multiple animations to be grouped and run concurrently 

Note: The delegate and removedOnCompletion properties of animations in the animations property are currently ignored. 

您可以通过简单的beginTime设置为持续时间使用动画的beginTime的组以启动一个动画另一个结束后的其他动画。 Time Warp in Animation提供了从CAMediaTiming协议继承的属性的很好的解释。但是,对于您的情况,向图层添加一个动画并使用委托对其进行注册并在第一个完成后向图层添加另一个动画可能会更方便。

+0

感谢您的解释。我以与您所建议的相同的方式执行,并且工作正常。 – andyPaul