IT English Collection(8)之Main event loop
2013-09-25 09:20
330 查看
1 前言
今天我们来学习一篇有关IOS事件循环的文章,具体如下。(特此声明:从此篇文章起,其集数与深入学习IOS系列同步,方便大家一起学习,如果错误地方请给与纠正,互相学习,十分感谢!)2 详述
2.1 正文
In the main event loop, an application continuouslyroutes incoming events to objects for handling and, as a result of that handling, updates its appearance andstate. An event loop is simply a run loop: an event-processing loop forscheduling work andcoordinating the
receipt of events from various input sources attached to the run loop. Every thread has access to a run loop. In all but the main thread, the run loop must be configured and run manually by your code. In Cocoa applications,
the run loop for the main thread—the main event loop—is run automatically by the application object. Whatdistinguishes the main event loop is that its primary input source receives events from the operating system that are
generated by user actions—for example, tapping a view or entering text using a keyboard.
The Application Object Gets and Dispatches Events
Just after an application is launched, it sets up the infrastructure for the main event loop. Itestablishes a connection with thoseunderlying system components that are responsible for
thedelivery of low-level user events. The application receives these events through an input source installed in the main thread’s run loop. Because the application must handle each event separately, in order of its arrival,
these low-level events are placed in a first-in first-out event queue.
Once the initial user interface is on the screen, the application is
thereafter driven by external events. The application object obtains the
topmost object in the event queue, converts it to an event object (UIEvent on iOS, NSEvent on OS X), and dispatches it to other objects in the application for handling. When the call that dispatched the event returns, the application fetches the next
object in the queue and dispatches it. It continues doing this until the applicationterminates.
Core Objects Respond to Events and Draw the User Interface
When an application is launched, it also sets up a core group of objects that are responsible for drawing the user interface and handling events. These core objects include windows and various kinds of views. When the application object gets an event from
the event queue, it dispatches it to the window in which the user event occurred. The window sends the event to the view that is the mostappropriate handler for it:
For multitouch and mouse events, the view is the one under the touch or mouse pointer.
For keyboard, motion, and other events, the view is the first responder.
If this initial view does not handle the event, it can pass it to other views in the applicationvia the responder chain.
In handling the event, the view often initiates a series of actions that modify the appearance of the application and update the application’s state and data. When these actions have been completed, control returns to the application, which fetches the
next event from the event queue.
2.2 生词
route [ruːt] vt. 按某路线发送schedule ['ʃedjuːl; 'sked-] vt. 安排,计划
coordinate [kəʊ'ɔ:dɪneɪt] vt. 调整;整合
receipt [rɪ'siːt] vt. 收到
various ['veərɪəs] adj. 各种各样的
manually ['mænjuəli] adv. 手动地
distinguishes [dɪ'stɪŋgwɪʃ] vt. 区分;辨别
dispatch [dis'pætʃ] vt. 派遣,派出
infrastructure ['ɪnfrəstrʌktʃə] n. 基础设施;公共建设
establish [ɪ'stæblɪʃ; e-] vt. 建立;创办
underlying [ʌndə'laɪɪŋ] adj. 潜在的;根本的
components [kəm'pəunənt] n. 部件;组件
delivery [dɪ'lɪv(ə)rɪ] n. [贸易] 交付;分娩
thereafter [ðeər'ɑːftə] adv. 其后;从那时以后
topmost ['tɒpməʊst] adj. 最高的;顶端的
terminate ['tɜːmɪneɪt] vt. 使终止;使结束
appropriate [ə'prəʊprɪət] adj. 适当的
via ['vaɪə] prep. 渠道,通过;经由
continuously [kən'tinjuəsli] adv. 连续不断地
3 结语
以上是所有内容,希望对大家有所帮助。相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- IT职场英语,必须学会
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- 英语基本用语总汇1000句 推荐
- 英语常用口语扫盲啦.扫盲!
- 通过event对象的fromElement属性解决热区设置主实体的一个bug
- .Net Winform开发笔记(一)
- JavaScript Event学习第十章 一些可替换的事件对
- JavaScript Event学习第九章 鼠标事件
- JavaScript Event学习补遗 addEventSimple
- javascript event 事件解析
- JavaScript Event学习第四章 传统的事件注册模型
- JS event使用方法详解
- javaScript window.event.keyCode 集合与测试方法
- JavaScript Event学习第六章 事件的访问
- javascript add event remove event
- Jquery替换已存在于element上的event的方法
- jquery利用event.which方法获取键盘输入值的代码
- JavaScript Event学习第七章 事件属性