【发布时间】:2014-02-24 14:43:05
【问题描述】:
我在CALayer 上有一个添加和删除动画的类别。我有一个完美运行的旋转动画,我有一个-endRotating 方法。以下是我的实现方式:
CAAnimation *anim = [self animationForKey:ROTATION_KEY];
if(anim){
[self removeAnimationForKey:anim];
}
anim是方法中CABasicAnimation的一个实例,是正确的。但是,[self removeAnimationForKey:anim]; 会导致将无法识别的选择器发送到我的动画实例:
-[CABasicAnimation length]: unrecognized selector sent to instance 0xba2bf40
这是 UIKit 中的错误,还是我做错了什么?
这是我的动画供参考:
-(void)beginRotatingWithAngularVelocity:(float)velocity{
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
rotationAnimation.fillMode = kCAFillModeForwards;
rotationAnimation.removedOnCompletion = YES;
rotationAnimation.repeatCount = 999999;
rotationAnimation.duration = velocity;
rotationAnimation.cumulative = YES;
rotationAnimation.fromValue = [NSNumber numberWithFloat:0];
rotationAnimation.toValue = [NSNumber numberWithFloat:M_PI * 2];
[self addAnimation:rotationAnimation forKey:ROTATION_KEY];
}
为什么 remove 方法试图访问我的动画的length?
【问题讨论】:
-
这只是一个错字。您正在传递实际的动画对象而不是 key sat eh 参数。
-
哎呀,我怎么看不到。谢谢。
标签: ios ios7 core-animation cabasicanimation caanimation