iPhone:无法识别 UIButton 上的多次触摸

发布于 2024-10-10 09:42:46 字数 220 浏览 0 评论 0原文

我有一个 UIButton(实际上是 UIButton 的子类),它通过 TouchsBegan: 和 TouchMoved: 函数与用户交互。

我希望用户能够按下按钮,将手指拖开,然后让第二根手指触摸按钮(而第一根手指从未离开过屏幕)。

问题是,第二个触摸事件永远不会调用touchesbegan:除非第一个手指已被释放。

有什么方法可以克服这个问题,还是我试图做不可能的事?

I have a UIButton (a subclass of one, actually) that interacts with the user via the touchesbegan: and touchesmoved: functions.

What I would like is for the user to be able to press down the button, drag their finger away, and have a second finger touch the button (all while the first finger has never left the screen).

Problem is, the second touch event never calls touchesbegan: unless the first finger has been released.

Is there some way to override this, or am I trying to do the impossible?

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

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

发布评论

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

评论(2

草莓味的萝莉 2024-10-17 09:42:46

您是否尝试将multipleTouchesEnabled设置为YES?

Have you tried setting multipleTouchesEnabled to YES?

一抹苦笑 2024-10-17 09:42:46

如果交互使用 touchesbegan:touchesmoved:,则使用 UIView 而不是 UIButton。按钮是 UIControl,与 UIControls 交互的方式是

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents.

我不确定这两种获取事件的方式能否很好地混合。

If the interactions are using touchesbegan: and touchesmoved: then use a UIView instead of a UIButton. A button is a UIControl, and the way to interact with UIControls is

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents.

I'm not sure this two ways of getting events mix well.

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