OStack程序员社区-中国程序员成长平台

标题: objective-c - iOS - 理解 UIPanGesture 上的 velocityInView [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 16:34
标题: objective-c - iOS - 理解 UIPanGesture 上的 velocityInView

我正在使用 UIPanGesture 返回velocityInView,据我收集的信息,它应该是每秒返回点数。我得到的是数以亿计的数字和很多零……我在模拟器中移动鼠标的速度没有那么快。

我觉得……

提前感谢您提供的任何帮助/建议。

编辑:请求的代码。

显示/调用

-(void)handlePanGestureUIPanGestureRecognizer *) 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]);
    }
}

Image here of output since I'm still below 10 rep



Best Answer-推荐答案


没有你的代码很难说...

CGPoint 由 CGFloats 组成,取决于您打印它们的方式,您可能会得到意想不到的结果

您传递给velocityInView: 的 View 必须在 View 层次结构中,在将其传递给velocityInView: 方法之前,通过查看 View 上的window 属性来检查它

关于objective-c - iOS - 理解 UIPanGesture 上的 velocityInView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4878901/






欢迎光临 OStack程序员社区-中国程序员成长平台 (http://ostack.cn/) Powered by Discuz! X3.4