2012-08-27 25 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