2

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

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

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

4

1 回答 1

1

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

swipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight;

swipeGestureRecognizer你的实例在哪里UISwipeGestureRecognizer

于 2016-12-27T11:24:25.530 回答