为什么 ipad 返回无效的触摸位置?
我注意到我们的应用程序崩溃了,并将其追溯到一个有趣的问题。
我有一个 320x480 的 UIVIew。它重写touchesEnded:withEvent:并检查触摸位置以执行一些逻辑。
有趣的是,(仅)在 ipad 上,我们收到 X 范围从 0 到 320...包含的触摸事件。这是重要的一点。
宽度为 320 像素的视图如何可能具有 321 个不同的触摸位置?这是一个已知的错误吗?这其中有什么原因吗?
要复制此操作,请在 ipad 上运行您的 iPhone 应用程序(在兼容性模拟器模式下),在视图中触摸并将手指滑离一侧或另一侧。您将收到 x 值为 0 或 320 的触摸事件。您也可以对 Y 执行此操作。我无法在 iPhone 上复制这个。
I noticed a crash in our application, and traced it back to an interesting problem.
I have a UIVIew that is 320x480. It overrides touchesEnded:withEvent: and checks the touch location to do some logic.
The interesting thing is that on ipad (only) we were receiving touch events with an X range from 0 to 320... inclusive. That's the important bit.
How does a view with 320 pixels across have a potential for 321 different touch locations? Is this a known bug? Is there some reason for it?
To replicate this, run your iphone app on an ipad (in the compatibility emulator mode), touch down in a view and slide your finger off one side or the other. You'll receive a touch event with an x value of 0 or 320. You can do this for Y too. I can't replicate this on an iphone.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
电容式触摸显示屏上的触摸实际上并不是单个像素,更可能是一个只有可能位置和直径的模糊噪声斑点。因此,这可能是模拟测量和事件处理程序之间进行一些后处理调整的结果。
或者这也可能只是一个错误。继续向 Apple 报告。
A touch on a capacitive touch display isn't physically a single pixel, more likely a fuzzy noisy blob with only a probable location and diameter. So this could be a result of some post processing adjustments between the analog measurements and the event handler.
Or this could also just be a bug. Go ahead and report it to Apple.