【发布时间】:2021-08-19 23:25:06
【问题描述】:
我正在使用 UIPanGestureRecognizer 来跟踪手指的运动。用户最初可能会非常快速地平移,但随后可能会在屏幕上的某个点保持几秒钟左右而不松开手指。我想检测这种过早的“拖动结束”事件何时发生。我尝试使用速度检测这一点,但它并不总是可靠的。
let location = panGesture.location(in: selectedCell.superview)
let velocity = panGesture.velocity(in: selectedCell.superview)
NSLog("Velocity, \(velocity)")
switch panGesture.state {
case .began:
break
case .changed:
let delta = panGesture.translation(in: self)
if velocity.x <= 0.05 && velocity.y <= 0.05 {
NSLog("Velocity 0!!!!")
}
panGesture.setTranslation(.zero, in: self)
break
【问题讨论】:
标签: ios uiview uikit uipangesturerecognizer