UISwipeGestureRecognizer左方向无法识别

时间:2013-10-16 04:59:10

标签: swipe direction uiswipegesturerecognizer

我在 UIButton 上使用 UISwipeGestureRecognizer 连接到 IBAction handleSwipe:

- (IBAction) handleSwipe:(UISwipeGestureRecognizer*) swipeRecognizer {
 NSLog(@"handleSwipe: %i",[swipeRecognizer direction]);
}

不幸的是,只有正确的滑动被识别出来。我没有看到任何设置来限制向左或向右滑动。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

您提到的设置是iOS 3.2上引入的direction属性。要识别左右滑动,只需执行

swipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight;

其中swipeGestureRecognizerUISwipeGestureRecognizer的实例。