开发者

CABasicAnimation is removed in a UITableView

开发者 https://www.devze.com 2023-04-12 08:40 出处:网络
I have a UITable view which populates some cells. Few of the cells have a spinning image. The image is spinned using an animation:

I have a UITable view which populates some cells.

Few of the cells have a spinning image. The image is spinned using an animation:

[image.layer removeAllAnimations];
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.duration = 1.0;
rotationAnimation.toValue = [NSNumber numberWithFloa开发者_Python百科t: M_PI * 2.0 * 1.0 * rotationAnimation.duration ];
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = HUGE_VALF; 
[image.layer addAnimation:rotationAnimation forKey:nil];

For some reason, not all images have the animation. It almost seems like when I start scrolling the table, some of the animations are removed/disabled.

For some reason


Change your last line to use a random key:

[image.layer addAnimation:rotationAnimation forKey:[NSString stringWithFormat:@"%d", arc4random()]];

This fixed it in my case.

0

精彩评论

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