2

我有一个填充一些单元格的 UITable 视图。

很少有细胞具有旋转图像。使用动画旋转图像:

[image.layer removeAllAnimations];
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.duration = 1.0;
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 * 1.0 * rotationAnimation.duration ];
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = HUGE_VALF; 
[image.layer addAnimation:rotationAnimation forKey:nil];

由于某种原因,并非所有图像都有动画。似乎当我开始滚动表格时,一些动画被删除/禁用。

由于某些原因

4

1 回答 1

0

更改最后一行以使用随机密钥:

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

这在我的情况下解决了它。

于 2013-04-09T10:18:32.170 回答