0

如果我试图识别从左到右或从左到右的滑动动作。我是否需要使用UISwipeGestureRecognizer带有UISwipeGestureRecognizerDirectionLeft方向的 a 然后动态添加UISwipeGestureRecognizer带有UISwipeGestureRecognizerDirectionRight方向的另一个?

那么当用户抬起手指时,我会移除带有UISwipeGestureRecognizerDirectionRight方向的手势识别器吗?

4

1 回答 1

2

如果我对您的理解正确,并且您只想检测从左到右的手势,则只需使用UISwipeGestureRecognizerDirectionRight. 这是一个例子:

UISwipeGestureRecognizer *swipeLeftToRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(myMethod:)];
[swipeLeftToRight setDirection:UISwipeGestureRecognizerDirectionRight];
[swipeLeftToRight setDelegate:self];
[someView addGestureRecognizer:swipeLeftToRight];
于 2012-09-07T21:03:03.417 回答