你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> IT English Collection(8)之Main event loop

IT English Collection(8)之Main event loop

編輯:IOS開發綜合
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 and state. 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 結語     以上是所有內容,希望對大家有所幫助
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved