iOS 触摸事件

发布于 2024-10-04 14:14:31 字数 129 浏览 1 评论 0原文

只是好奇。当用户在 iPhone 应用程序中触摸屏幕时,操作系统如何处理触摸事件?当前代码块(函数/方法)是否完成,然后触摸事件得到处理?或者操作系统是否会中断正在运行的任何代码来处理触摸事件?

谢谢!

阳光明媚

Just curious. When the user touches the screen in an iPhone app, how does the OS handle the touch event? Does the current code block (function/method) finish, and then the touch event gets handled? Or does the OS interrupt whatever code may be running to handle the touch event?

Thanks!

Sunny

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

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

发布评论

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

评论(2

合约呢 2024-10-11 14:14:31

触摸屏幕会导致操作系统为您的应用程序生成触摸事件。所有事件都在主线程(运行代码的同一线程)中处理,该线程的实现类似于循环。操作系统不会中断您的代码来处理事件;所有事件都会在事件循环的下一次传递时得到处理。

Touches to the screen cause the OS to generate touch events for your app. All events are handled in the main thread (the same thread that runs your code) which is implemented like a loop. The OS does not interrupt your code to handle an event; all events get handled at the next pass of the event loop.

婴鹅 2024-10-11 14:14:31

如果当前函数/方法在主线程中运行,则在当前例程返回(到运行循环)之前不会调用任何触摸事件处理程序。如果当前函数/方法未在主 UI 线程中运行,则可以中断代码以运行触摸事件处理程序。

在当前设备上,触摸事件似乎被量化为 60 Hz 帧速率,大约每 16 毫秒一次,因此直到该时间过去之前,物理触摸可能不会作为事件发布,并且在此之后不会调用任何处理程序该事件已发布。

If the current function/method is running in the main thread, then any touch event handler will not be called until after the current routine returns (to the run loop). If the current function/method is not running in the main UI thread, then the code could be interrupted to run the touch event handler.

On current devices, touch events seem to be quantized to the 60 Hz frame rate, roughly every 16 mSec, so a physical touch may not be posted as an event until up to that time may have passed, and no handler will be called until after the event is posted.

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