同时按下两个按钮
我的应用程序有 2 个按钮,靠近。
我试图仅用一根手指同时触摸这两个按钮。
有没有办法检查这两个按钮是否同时触摸?
My app has 2 buttons, near.
I'm trying to touch this two buttons, at the same time, using only one finger.
There is a way to check if the touch is over this two buttons at same time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以(但实际上不应该)像 Abizern 所说的那样用一根手指触摸 2 个按钮,但你也可以调用 2 个方法来实现一键触摸。例如:
然而,对于您想要做的事情来说,这并不总是正确的行为,因此从 iOS 3 开始,我们可以使用 UITouch 和事件机制进行一些调整来解决很多问题:
}
You can (but really shouldnt) touch 2 buttons with one finger like Abizern said, but you can also call 2 methods for one button touch. For example:
However, this is not always the correct behavior for what you're trying to do, so starting with iOS 3, we can use a bit of jiggering with the UITouch and event mechanism to figure a lot of it out:
}
一次触摸就是一个点。尽管建议制作合理大小的控件,但当您触摸屏幕时,您得到的是一个点,而不是一个区域。该点将位于一个或另一个控件中。
您可以尝试拦截触摸并将其变成更大的矩形,看看是否同时覆盖两个按钮。
编辑
看看这个SO问题 查看拦截触摸的一种方法。
A touch is a point. Although the recommendation is to make controls of a reasonable size, when you touch the screen, you are getting a point, not a region. That point is going to be in one or other of the controls.
You could try to intercept the touch and turn it into a larger rectangle and see if that covers both the buttons at the same time.
EDIT
Have a look at this SO question to see one way of doing intercepting touches.