gpt4 book ai didi

ios - UISwipeGestureRecognizer 向左滑动手指并向上滑动

转载 作者:行者123 更新时间:2023-12-01 18:53:06 28 4
gpt4 key购买 nike

我正在使用 UISwipeGestureRecogizer刷卡leftright通过使用 UISwipeGestureRecognizerDirectionRightUISwipeGestureRecognizerDirectionLeft它工作得很好,但默认的滑动太敏感了,它只是比点击多一点。

有什么方法可以让它像 scrollView 时一样工作在其 paging enable 时工作属性是真实的,直到用户没有抬起手指,它才起作用。
如果 View 不随着手指移动而移动,那会很好,并且仅在 left 时才有效。或 right执行手势并抬起手指。谢谢。

最佳答案

一个 UISwipeGestureRecognizer不会为您提供任何更改灵敏度或滑动的任何其他方面的选项。要获得对滑动的更多控制,您可以使用以下方法之一:

UIPanGestureRecognizer

这里有一些可以尝试的 UIPanGestureRecognizer :

- (void)handleGesture:(UIPanGestureRecognizer *)gestureRecognizer{
CGPoint velocity = [gestureRecognizer velocityInView:yourView];
if(velocity.x > 0){
//Right gesture
}else{
//Left gesture
}
}

UIResponder

全部 UIViews继承自 UIResponder ,因此您可以使用 touchesBegan , touchesMovedtouchesEnded计算触摸的方法。尝试这样的事情:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
UITouch *touch = [touches anyObject];
start = [touch locationInView:self.view];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint end = [touch locationInView:self.view];
//Compare start and end points here.
}

关于ios - UISwipeGestureRecognizer 向左滑动手指并向上滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29666921/

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