ios - View 中的 UIPanGestureRecognizer 速度可能为零?

标签 ios uipangesturerecognizer

UIPanGestureRecognizer中,有一个计算手势速度的函数:

func velocity(in view: UIView?) -> CGPoint

doc说:

view
The view in whose coordinate system the velocity of the pan gesture is computed.

我注意到 view 可能是 nil,这有点奇怪。我们为什么以及什么时候应该使用 nil

最佳答案

我相信它的工作方式与 location(in view: UIView?) 相同做。如果您不传递 View 对象,那么它将计算窗口坐标系中的速度。

location(in:)

The view object in whose coordinate system you want the touch located. A custom view that is handling the touch may specify self to get the touch location in its own coordinate system. Pass nil to get the touch location in the window’s coordinates.

关于ios - View 中的 UIPanGestureRecognizer 速度可能为零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47697639/

相关文章:

iphone - 在 Xcode 中有条件地链接第三方 API

ios - 如何欺骗 UIScrollView 在平移中间开始滚动?

ios - 如何通过 panGestureRecognizer 启用 collectionView 分页

ios - 手指拖动 UIButton 与 UIImageView 重叠时检测

ios - 将自定义对象存储在UILocalNotification的userInfo中而不进行编码

iOS 在禁用按钮上进行内部修饰

ios - AVAudioEngine 可以创建的节点数量是否有限制?

ios - UIButton 不可点击但可接收手势

iOS:获取当前对象的真实位置

ios - 更改 View 的边界不会更改它绘制的位置