使用具有 3 次触摸而不是 1 次触摸的 UIScrollView
我想知道是否有某种方法可以使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您将三个手指按下,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.您可以通过子类化
UIScrollView
来实现您的想法,然后在touchedBegan/Moved/Ended
中实现不同的行为,修改触摸并将它们传递给超类(如果需要)。我个人认为你不应该引入复杂的手势。大多数人已经遇到了两个手指手势的问题。我花了一年的时间才发现 Maps.app 中的两根手指点击也可以进行缩放。 (也许我比较笨)
You can probably implement your idea by subclassing
UIScrollView
and then implement a different behaviour intouchedBegan/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)