我有一个UIScrollView,里面有2个图像。我有平移,捏和旋转手势连接到滚动视图,一切正常。但是,当我点击在滚动视图上执行操作的按钮时,平移将重置为其中心。捏缩放和旋转不会重置它们的值,但是平移。如何将其编码为不重置为中心但触摸时仍然不会飞离屏幕?
这是我的平移手势代码:
- (IBAction)handlePan:(UIPanGestureRecognizer *)recognizer {
CGPoint translation = [recognizer translationInView:self.view];
recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,
recognizer.view.center.y + translation.y);
[recognizer setTranslation:CGPointMake(0, 0) inView:self.view];
}
非常感谢任何帮助