【问题标题】:Detect only a rotation gesture from right to left仅检测从右到左的旋转手势
【发布时间】:2013-07-18 20:35:20
【问题描述】:

我能够检测到旋转手势,但我只需要检测从右到左的那个。

非常感谢任何帮助。

谢谢!

【问题讨论】:

  • 您的意思是通过物理旋转设备触发的加速度计事件吗?或者你的意思是一些在屏幕上旋转的触摸手势?两者都在Event Handling Guide for iOS 中讨论。如果您在查看该指南后需要更多帮助,请准确说明您的意思是哪种“旋转手势”。
  • 我的意思是触摸手势。感谢您的回复。

标签: ios rotation gesture right-to-left


【解决方案1】:

我假设您正在使用 UIRotationGestureRecognizer 来检测旋转。你应该有这样的东西:

UIRotationGestureRecognizer *gestureRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(gestureRecognizerAction:)];
[self.view addGestureRecognizer:gestureRecognizer];

和:

- (void)gestureRecognizerAction:(UIRotationGestureRecognizer *)gestureRecognizer
{
  if (gestureRecognizer.rotation > 0) {
     //rotation in one side - lets say from left to right
  } else {
     //rotation in other side - lets say from right to left
  }
}

通过这种方式,您将只能检测到从右到左的旋转。

【讨论】:

  • 谢谢拉法尔!我错过了 gestureRecognizer 对象的旋转方法。
猜你喜欢
  • 1970-01-01
  • 2018-09-04
  • 1970-01-01
  • 2011-07-23
  • 1970-01-01
  • 1970-01-01
  • 2013-08-13
  • 1970-01-01
  • 2011-05-07
相关资源
最近更新 更多