视图中的 UIPanGestureRecognizer 速度可能为零?
UIPanGestureRecognizer velocity in view could be nil?
在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?)
相同。如果您不传递视图对象,那么它将计算 window 坐标系中的速度。
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.
在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?)
相同。如果您不传递视图对象,那么它将计算 window 坐标系中的速度。
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.