CABasicAnimation is removed in a UITableView
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.
精彩评论