gpt4 book ai didi

iphone - UISwipeGestureRecognizer 无需触摸

转载 作者:行者123 更新时间:2023-11-29 03:59:56 26 4
gpt4 key购买 nike

我如何识别UISwipeGestureRecognizerUISwipeGestureRecognizerDirectionUp然后紧接着,无需抬起手指,就识别出 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com