gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 11:38:49 40 4
gpt4 key购买 nike

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/

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