获取 UISwipeGestureRecognizer - 自定义手势识别器的速度?

发布于 2024-10-27 10:25:34 字数 415 浏览 4 评论 0原文

我有一个播放视频的应用程序。我想通过手势控制视频,即从左向右滑动可向前,从右向左滑动可向后。

我之前曾就该主题提出过问题,但当时该项目还只是一个想法。现在我要坐下来自己编码,我不知道该怎么做。

回答者补充说,我可能需要创建一个自定义手势识别器来获取滑动的速度,我希望这个速度能够影响视频的速度。

有什么想法我该怎么做吗?

我以前从未构建或配置过手势识别器,所以我不知道如何去做?

我真正想要的是一种处理开始和结束方法的方法。我想我可以在两者之间运行一个计时器并计算出 X 和 X 。 Y 计算速度。任何帮助、代码示例等都会有所帮助。

干杯

I have an app that plays a video. I want to control the video by Gesture i.e. swipe left-to-right for forwards and right-to-left for backwards.

I previously asked a question on the topic, but that was when the project was but an idea. Now I am to sit down and code the thing myself I have no idea what to do.

The answerer added that I may need to create a custom gesture recogniser to get the speed of the swipe, I wish this speed to affect the speed of the video.

Any ideas how I would go about this?

I've never built or configured a gesture recogniser before so I've no idea how to go about it?

What I really want is a way to handle the begin and end methods. I think I can get a timer running between the two and work out the X & Y to calculate the speed. Any help, code-samples and the like will help.

Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

新一帅帅 2024-11-03 10:25:34

一种方法是计算 touchesBegantouchesEnded 之间的时间差和 x 位置差。使用这两个数字,您可以计算“每秒像素数”或类似的值。然后,您可以使用结果的大小作为视频速度的系数。

One way would be to calculate the time difference and x-position difference between touchesBegan and touchesEnded. Using these two numbers, you can calculate "pixels per second", or similar. You can then use the magnitude of the result to act as the coefficient of the speed of the video.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文