我有一个非常奇怪的问题,我正在我的应用程序中实现 UIRotationGestureRecognizer 来旋转图像。我的问题是,有时当您开始旋转图像时,它会跳到另一根手指。示例:我用一根手指拖动图像,然后用第二根手指开始旋转,但图像转到第二根手指。这正常吗?可以修复吗?我正在使用的代码是:
if([recognizer state] == UIGestureRecognizerStateEnded) {
prevRotation = 0.0;
return;
}
CGFloat newRotation = 0.0 - (prevRotation - [recognizer rotation]);
CGAffineTransform currentTransformation = image.transform;
CGAffineTransform newTransform = CGAffineTransformRotate(currentTransformation, newRotation);
image.transform = newTransform;
prevRotation = [recognizer rotation];
我尝试保存中心的最后一个位置并再次应用它,但它也不起作用,如下所示:
lastPoint=image.center;
if([recognizer state] == UIGestureRecognizerStateEnded) {
prevRotation = 0.0;
return;
}
CGFloat newRotation = 0.0 - (prevRotation - [recognizer rotation]);
CGAffineTransform currentTransformation = image.transform;
CGAffineTransform newTransform = CGAffineTransformRotate(currentTransformation, newRotation);
image.transform = newTransform;
prevRotation = [recognizer rotation];
image.center=lastPoint;