gpt4 book ai didi

objective-c - UIGestureRecognizer State Changed 和 touchesMoved 之间有什么区别?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:05:42 25 4
gpt4 key购买 nike

我正在研究在 LongPressGesture 之后拖动 UIView。一些代码使用 touchesMoved:,一些代码检查 UIGestureRecognizerStateChange .还是不明白,哪个更好?

最佳答案

来自manual :

When a gesture recognizer recognizes a discrete gesture, it sets the state property to UIGestureRecognizerStateRecognized. If the gesture is continuous, it sets the state property first to UIGestureRecognizerStateBegan; then, for each change in position of the gesture, it sets (or resets) the property to UIGestureRecognizerStateChanged. When the gesture ends, it sets state to UIGestureRecognizerStateEnded. If at any point a gesture recognizer realizes that this multitouch sequence is not its gesture, it sets its state to UIGestureRecognizerStateFailed.

因此,如果用户触摸屏幕总是会生成一个 touchedMoved 事件,并且如果它处于连续手势的中间,它也会导致设置 UIGestureRecognizerStateChanged 状态。

关于objective-c - UIGestureRecognizer State Changed 和 touchesMoved 之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14227465/

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