以任何角度滑动检测 [英] Swipe detection in any angle
本文介绍了以任何角度滑动检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么方法可以在任何角度检测iPhone中的滑动吗? UISwipeGestureRecognizer
似乎只有4个方向。
如果我这样滑动:
Is there any way I can detect swipe in iPhone in any angle? UISwipeGestureRecognizer
seems to have only 4 directions.
If I swipe like this:
\
\
\
X
我希望它给我60度的东西,而不仅仅是像 UISwipeGestureRecognizer
那样。
我该怎么做?
I want it to give me something like 60 degrees and not just down like the UISwipeGestureRecognizer
.
How can I do this?
推荐答案
您可以使用 UIPanGestureRecognizer
。当您检测到Ended状态时,您可以获得速度。速度分为x和y分量。您可以使用x和y分量来计算斜率m。
You can use a UIPanGestureRecognizer
. When you detect the Ended state you can get the velocity. The velocity is broken into x and y components. You can use the x and y components to calculate the slope, m.
m =Δy/Δx
m = ∆y / ∆x
这篇关于以任何角度滑动检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文