我使用 GestureRecognizer 代表进行捏合、平移、旋转、长按图像。我用UIPinchGestureRecognizer
委托来捏。
但是,当我捏缩放时它没有任何问题。当我缩小某个级别时,图像很小,我无法放大缩小图像。之后,当我应用平移时,当我松开手指时,平移将应用整个视图并且仅应用图像。松开我的手指后,平底锅只应用图像。触摸图像平移后应用于整个视图
代码:
UIPinchGestureRecognizer *pinchGesture1 = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(ahandlePinch1:)];
[myImageView addGestureRecognizer:pinchGesture1];
-(void)ahandlePinch1:(UIPinchGestureRecognizer*)sender {
mCurrentScale += [sender scale] - mLastScale;
mLastScale = [sender scale];
if (sender.state == UIGestureRecognizerStateEnded)
{
mLastScale = 1.0;
}
CGAffineTransform currentTransform = CGAffineTransformIdentity;
CGAffineTransform newTransform = CGAffineTransformScale(currentTransform, mCurrentScale, mCurrentScale);
myImageView.transform = newTransform;
}