使用具有 3 次触摸而不是 1 次触摸的 UIScrollView

发布于 2024-08-20 02:56:27 字数 199 浏览 5 评论 0原文

我想知道是否有某种方法可以使用 UIScrollView 的三点触摸。我最终想要的是让 UIScrollView 只传递一次 UITouch (或者至少认为它只有一次触摸),但有 3 次触摸。我想使用中指或找到三个触摸的平均值 (x , y) 并使用该 (x , y) 作为发送到 UIScrollView 的一次触摸。如果有人知道或知道我如何完成此操作,请上传一些代码(如果可能)。

I wanted to know If there is some way I could use three touches with a UIScrollView. What I want in the end is to have the UIScrollView only be passed one UITouch (or at least think it it has only one touch), but have three touches down. I want to use the let's just say the middle finger or find the average (x , y) of the three touches and use that (x , y) as my one touch being sent to the UIScrollView. If anyone knows or has any idea how I may accomplish this then please upload some code if possible.

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

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

发布评论

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

评论(2

仙女山的月亮 2024-08-27 02:56:27

如果您将三个手指按下,UIScrollView 将不会滚动,因此您不必担心禁用默认行为。要用三个手指滚动它,请使用正常的触摸功能进行疯狂的数学运算以获得平均值,然后使用 - (void)setContentOffset:(CGPoint)contentOffsetAnimated:(BOOL)animated 自动滚动。

If you put three fingers down the UIScrollView won't scroll, so you don't have to worry about disabling the default behavior. To scroll it with three fingers, do your crazy math to get the average using the normal touch functions, and then use - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated to scroll automatically.

拔了角的鹿 2024-08-27 02:56:27

您可以通过子类化 UIScrollView 来实现您的想法,然后在 touchedBegan/Moved/Ended 中实现不同的行为,修改触摸并将它们传递给超类(如果需要)。

我个人认为你不应该引入复杂的手势。大多数人已经遇到了两个手指手势的问题。我花了一年的时间才发现 Maps.app 中的两根手指点击也可以进行缩放。 (也许我比较笨)

You can probably implement your idea by subclassing UIScrollView and then implement a different behaviour in touchedBegan/Moved/Ended, modifying the touches and passing them to the superclass if needed.

Personally I think you should not introduce complex gestures. Most people already have problems with two finger gestures. It took me a year to find out that two finger tap in Maps.app also did zooming. (Maybe I'm dumb though)

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