iphone – UISwipeGestureRecognizer滑动长度

iphone – UISwipeGestureRecognizer滑动长度,第1张

概述任何想法,如果有办法得到滑动手势或触摸的长度,以便我可以计算距离? 由于SwipeGesture触发方法,您可以在手势结束时触发一次您可以直接访问该位置的方法。 也许你想使用UIPanGestureRecognizer。 如果您可以使用平移手势,您将保存平移的起始点,如果平移已经结束计算距离。 - (void)panGesture:(UIPanGestureRecognizer *)sender 任何想法,如果有办法得到滑动手势或触摸的长度,以便我可以计算距离?解决方法 由于SwipeGesture触发方法,您可以在手势结束时触发一次您可以直接访问该位置的方法。
也许你想使用UIPanGestureRecognizer。

如果您可以使用平移手势,您将保存平移的起始点,如果平移已经结束计算距离。

@H_403_18@- (voID)panGesture:(UIPanGestureRecognizer *)sender { if (sender.state == UIGestureRecognizerStateBegan) { startLocation = [sender locationInVIEw:self.vIEw]; } else if (sender.state == UIGestureRecognizerStateEnded) { CGPoint stopLocation = [sender locationInVIEw:self.vIEw]; CGfloat dx = stopLocation.x - startLocation.x; CGfloat dy = stopLocation.y - startLocation.y; CGfloat distance = sqrt(dx*dx + dy*dy ); NSLog(@"distance: %f",distance); }} 总结

以上是内存溢出为你收集整理的iphone – UISwipeGestureRecognizer滑动长度全部内容,希望文章能够帮你解决iphone – UISwipeGestureRecognizer滑动长度所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1087188.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存