我正在尝试检测两个手指轻扫触摸并使用它像Mac中的触摸板(两个手指向上和两个手指向下听)和代码类似;
UISwipeGestureRecognizer *swipeUpTwoFinger = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeTwoFinger:)];
swipeUpTwoFinger.numberOfTouchesRequired = 2;
swipeUpTwoFinger.direction = UISwipeGestureRecognizerDirectionUp;
[self.view addGestureRecognizer:swipeUpTwoFinger];
UISwipeGestureRecognizer *swipeDownTwoFinger = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeTwoFinger:)];
swipeDownTwoFinger.numberOfTouchesRequired = 2;
swipeDownTwoFinger.direction = UISwipeGestureRecognizerDirectionDown;
[self.view addGestureRecognizer:swipeDownTwoFinger];
-(void)handleSwipeTwoFinger:(UISwipeGestureRecognizer *)swipeGestureRecognizer
{
if (swipeGestureRecognizer.direction == UISwipeGestureRecognizerDirectionUp) {
NSLog(@"handleSwipeUpTwoFinger");
}
else if (swipeGestureRecognizer.direction == UISwipeGestureRecognizerDirectionDown) {
NSLog(@"handleSwipeDownTwoFinger");
}
}
问题是
触摸时我可以进行向上或向下滑动,但只需按一下即可进行向上滑动。
我想要的就像Mac中的触摸板一样,当我向上轻扫它时,如果没有让电路板向下滑动它也可以听取它。
问题
我怎么能用UISwipeGestureRecognizer做到这一点? 或者它有限制不能做我想要的UIPanGestureRecognizer或听自己的各种触摸事件做逻辑吗?或任何其他实施?任何演示?
任何建议将不胜感激:)