Objective c ipad触摸动画

Objective c ipad触摸动画,objective-c,ipad,cabasicanimation,Objective C,Ipad,Cabasicanimation,我在用触摸设置轮子的动画时遇到了麻烦。我花了一些时间在持续时间、旋转时间和动画持续时间上输入不同的数字值,以便在thouchsMove上获得平滑的移动,但每次触摸发生时,轮子都会旋转,看起来它会跳回到原来的位置。如果有人能说明这一点,我将不胜感激 CABasicAnimation* rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rota

我在用触摸设置轮子的动画时遇到了麻烦。我花了一些时间在持续时间、旋转时间和动画持续时间上输入不同的数字值,以便在thouchsMove上获得平滑的移动,但每次触摸发生时,轮子都会旋转,看起来它会跳回到原来的位置。如果有人能说明这一点,我将不胜感激

CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.fillMode = kCAFillModeForwards;
rotationAnimation.removedOnCompletion = NO;
rotationAnimation.delegate = self; 

rotationAnimation.toValue = [NSNumber numberWithFloat: 2  * 1 * 45 ];
rotationAnimation.duration = 2;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = 1; 


rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];


[animatedImage.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

对于那些感兴趣的人来说,下面的代码是获得预期效果所需要的

CGAffineTransform transforms = CGAffineTransformConcat(animatedImage.transform,CGAffineTransformMakeRotation(M_PI/2));
animatedImage.transform = transforms;

如果您遇到相同的问题,请按照此示例进行操作,它会立即出现。

我无法重现重置。你能告诉我们是否有任何手势识别器或触摸处理与AnimateImage关联吗?嗨,我不确定我是否理解,我正在从-voidTouchsMoved:NSSet*TouchsWithEvent:UIEvent*event调用上述方法{因此,您通过触摸启动此动画,然后在动画结束后,它是否返回到其原始位置?不,确切地说,动画是在您保持触摸的同时被调用的。例如,想象一个音乐转盘,您用手指上下移动LP。我想通过在c中移动uiimageview来创建相同的效果不抬手指的圆周运动