Iphone 将平移手势识别器附加到图像上

Iphone 将平移手势识别器附加到图像上,iphone,Iphone,有人能告诉我需要做什么吗?我需要在图像上附加一个平移手势识别器,当我们移动时,它会顺时针和逆时针旋转 谢谢您需要将UIPangestureRecognitor附加到图像上,当调用动作方法时,您可以询问手势的当前平移和速度。然后根据这些值旋转图像。因为这是一个连续的手势,所以当平移手势改变时,会通知您,从而允许您更新图像的旋转 - 更新 我重读了你的问题,如果你想用手指做典型的旋转手势来旋转图像,你应该使用UIRotationGestureRecognitor而不是UIPangestureReco

有人能告诉我需要做什么吗?我需要在图像上附加一个平移手势识别器,当我们移动时,它会顺时针和逆时针旋转

谢谢

您需要将UIPangestureRecognitor附加到图像上,当调用动作方法时,您可以询问手势的当前平移和速度。然后根据这些值旋转图像。因为这是一个连续的手势,所以当平移手势改变时,会通知您,从而允许您更新图像的旋转

-

更新

我重读了你的问题,如果你想用手指做典型的旋转手势来旋转图像,你应该使用UIRotationGestureRecognitor而不是UIPangestureRecognitor。如果你想做一个左右移动手指的平移手势,你必须使用UIPangestureRecognitor。我只是想完成答案

添加旋转手势识别器:

UIRotationGestureRecognizer *rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
[self.myView addGestureRecognizer:rotationRecognizer];
[rotationRecognizer release];
处理手势并相应地旋转图像的最简单形式如下所示:

- (void)handleGesture:(UIRotationGestureRecognizer *)sender {
    self.myView.transform = CGAffineTransformMakeRotation(sender.rotation);
}
您需要将UIPangestureRecognitor附加到图像上,当调用动作方法时,您可以询问手势的当前平移和速度。然后根据这些值旋转图像。因为这是一个连续的手势,所以当平移手势改变时,会通知您,从而允许您更新图像的旋转

-

更新

我重读了你的问题,如果你想用手指做典型的旋转手势来旋转图像,你应该使用UIRotationGestureRecognitor而不是UIPangestureRecognitor。如果你想做一个左右移动手指的平移手势,你必须使用UIPangestureRecognitor。我只是想完成答案

添加旋转手势识别器:

UIRotationGestureRecognizer *rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
[self.myView addGestureRecognizer:rotationRecognizer];
[rotationRecognizer release];
处理手势并相应地旋转图像的最简单形式如下所示:

- (void)handleGesture:(UIRotationGestureRecognizer *)sender {
    self.myView.transform = CGAffineTransformMakeRotation(sender.rotation);
}