如何测量 Table 视图滚动的速度?
How to measure velocity of Table View's scrolling?
我想根据用户滚动的速度调用或不调用方法。
它必须在用户手指移动时立即测量,因为该方法需要在它开始移动的那一秒调用或忽略,而不是在它停止时调用。
这对我有用。
CGPoint scrollVelocity = [[self.tableView panGestureRecognizer] velocityInView:self.tableView];
NSLog(@"scroll velocity : %f",scrollVelocity.y);
此方法公开速度值。它是滚动视图委托的一部分。
optional func scrollViewWillEndDragging(_ scrollView: UIScrollView,
withVelocity velocity: CGPoint,
targetContentOffset: UnsafeMutablePointer<CGPoint>){
}
我想根据用户滚动的速度调用或不调用方法。
它必须在用户手指移动时立即测量,因为该方法需要在它开始移动的那一秒调用或忽略,而不是在它停止时调用。
这对我有用。
CGPoint scrollVelocity = [[self.tableView panGestureRecognizer] velocityInView:self.tableView];
NSLog(@"scroll velocity : %f",scrollVelocity.y);
此方法公开速度值。它是滚动视图委托的一部分。
optional func scrollViewWillEndDragging(_ scrollView: UIScrollView,
withVelocity velocity: CGPoint,
targetContentOffset: UnsafeMutablePointer<CGPoint>){
}