我如何识别UISwipeGestureRecognizer
与 UISwipeGestureRecognizerDirectionUp
然后紧接着,无需抬起手指,就识别出 UISwipeGestureRecognizerDirectionDown
识别器?
基本上我想要多个UISwipeGestureRecognizers
当我改变方向时,无需抬起手指即可识别。
到目前为止我的代码...
- (void)viewDidLoad {
UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(screenSwipedUp)];
swipeUp.numberOfTouchesRequired = 1;
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
swipeUp.cancelsTouchesInView = NO;
[self.view addGestureRecognizer:swipeUp];
UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(screenSwipedDown)];
swipeDown.numberOfTouchesRequired = 1;
swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
swipeDown.cancelsTouchesInView = NO;
[self.view addGestureRecognizer:swipeDown];
}
- (void)screenSwipedUp {
NSLog(@"SW-Up");
}
- (void)screenSwipedDown {
NSLog(@"SW-Down");
}
最佳答案
我认为你不能用 UISwipeGestureRecognizer 做到这一点.您可以改为使用 UIPanGestureRecognizer并实现该操作或创建 UIGestureRecognizer 的子类和 Override the methods识别您的特殊手势。
关于iphone - UISwipeGestureRecognizer 无需触摸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15997381/