2010-09-29 70 views

回答

6

你要附加一个UIPanGestureRecognizer的形象和时的动作方法被调用时,你可以要求手势的当前翻译和速度。然后根据这些值旋转图像。由于这是一个连续的手势,当平移手势发生变化时会通知您,允许您更新图像的旋转。

UIPanGestureRecognizer Class Reference

-

更新

我重读你的问题,如果你想通过做典型的旋转手势来旋转用你的手指图像,你应该使用UIRotationGestureRecognizer而不是UIPanGestureRecognizer。如果你想做一个平移手势左右移动你的手指,你将不得不使用UIPanGestureRecognizer。我只想完成答案。

添加的旋转手势识别:

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); 
} 
+0

感谢的Yannick:d – awlcs 2010-09-30 15:04:30