开发者

How to reactivate an applied CABasicAnimation or check if a CABasicAnimation is actually running right now?

This is strange:

I have a view co开发者_如何转开发ntaining a rotated CALayer. The layer is rotated using a CABasicAnimation on the transform.rotation.z keypath. Works fine.

Then the view including that layer becomes deallocated, and some time later I load everything again. I re-create the view and the rotated layer, and apply that CABasicAnimation. In some situations the animation just won't start.

So what I do next is this: Performing a delayed selector to kick the animation, should it be stalled. But since kicking it while it is already running causes a noticeable hitch on the screen, I check if the animation object exists:

CABasicAnimation *anim = [rotatedLayer animationForKey:@"transform.rotation.z"];
if (!anim) {
    [self startRotating];
}

Unfortunately, when the animation is not taking place, I do have a CABasicAnimation object applied. Logically, because I created it. The animation just won't start. However, when I then go ahead and apply it once again after one second or so, then it works.

I even get the animiationDidStart message from the delegate:

- (void)animationDidStart:(CAAnimation *)theAnimation {
    NSLog(@"animation started!!!!");
}

There's a good chance that this is not a bug but a feature.

Is there a way to give that CABasicAnimation object a kick to make it run, even if CoreAnimation thinks that it is running already (which is not the case sometimes), without giving it a kick in the butt when it actually really was running already?


Go through the pause and resume of animation as given in Apple's Technical Q&A

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜