如何为UISwipeGestureRecognizer设置更多方向?
UISwipeGestureRecognizer
有四个方向可以设置:上、下、右、左。
但当我尝试设置时,滑动的方向似乎需要非常精确。我的意思是,例如,如果我设置一个具有 toUp 方向的 UISwipeGestureRecognizer,并且如果我滑动手指的方向不是那么精确,例如在向上和向右中间 45 度,则 UISwipeGestureRecognizer< /code> 无法获取它。
但我注意到对于 UIScrollView
来说,情况并非如此。
那么我怎样才能为 UISwipeGestureRecognizer
提供更多方向或者如何使方向检查更轻松?
谢谢
UISwipeGestureRecognizer
has four directions that I can set: up, down, right, left.
but as I tried to set, the direction of a swipe seems need to be quite precise. I mean, for example, if I set a UISwipeGestureRecognizer
with toUp direction, and if I swipe my finger not that precise toUp, say 45 degree in the middle of up and right, the UISwipeGestureRecognizer
can't get it.
But I noticed that for UIScrollView
, it is not the case.
So How can I give more directions for UISwipeGestureRecognizer
or how can I make the direction check more relax?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好使用苹果的滑动手势,以与他们的应用程序保持一致。您可以尝试通过子类化 UISwipeGestureRecognizer 来定义自己的类,或者使用旧的 UITouchesBegan、UITouchesEnded 等方法创建自己的类。
It's probably best to use Apple's swipe gesture to be consistent with their Apps. You could try defining your own by subclassing the UISwipeGestureRecognizer, or creating your own class using the older UITouchesBegan, UITouchesEnded, etc methods.