iOS - 了解UIPanGesture上的velocityInView [英] iOS - Making sense of velocityInView on UIPanGesture
问题描述
我正在使用UIPanGesture来返回velocityInView,从我收集它应该是每秒返回点数。我得到的是数以亿计的数字和很多零...我不会在模拟器中快速移动我的鼠标。
I'm using a UIPanGesture to return velocityInView and from what I gather it's supposed to be returning points per second. What I am getting is numbers in the hundreds of millions and a lot of zeros... I'm not moving my mouse that quickly in the simulator.
我想。 ..
提前感谢您提供的任何帮助/建议。
Thanks in advance for any help/advice you have.
编辑:请求的代码。
显示/通话
-(void)handlePanGesture:(UIPanGestureRecognizer *) recognizer
{
if (recognizer.state == UIGestureRecognizerStateChanged ||
recognizer.state == UIGestureRecognizerStateBegan)
{
CGPoint vel = [recognizer velocityInView:myScrollView];
//[self doSpinAnimationWithVelocity:vel.x];
NSLog([NSString stringWithFormat:@"Velocity - X-Axis - %d ", vel.x]);
NSLog([NSString stringWithFormat:@"Velocity - Y-Axis - %d ", vel.y]);
}
}
推荐答案
没有你的代码很难说...
without your code its hard to say...
CGPoint是由CGFloats组成,取决于你如何打印它们你可能会得到意想不到的结果
CGPoint is made up of CGFloats, depending on how you are printing them you could be getting unexpected results
你传递给velocityInView的视图:必须在视图层次结构中,检查它在将视图传递给velocityInView:方法
The view you pass into velocityInView: must be in the view hierarchy, check it by looking at the window property on the view before you pass it into the velocityInView: method
这篇关于iOS - 了解UIPanGesture上的velocityInView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!