[UIApplication]簡介

來源:互聯網
上載者:User

標籤:

The UIApplication class provides a centralized point of control and coordination for apps running on iOS. Every app must have exactly one instance of UIApplication (or a subclass of UIApplication). When an app is launched, the UIApplicationMain function is called; among its other tasks, this function creates a singleton UIApplication object. Thereafter you access this object by invoking the sharedApplication class method.

UIApplication類提供了運行在iOS上的apps的控制和協調的集中點。每個應用都必須有一個確切的UIApplication執行個體(或者UIApplication的子類)。當一個app運行時

UIApplicationMain 方法會被調用;在它的其它任務中,這個方法建立了一個單個UIApplication對象。此後通過調用sheredApplication 類方法來訪問這個對象。

 

A major role of a UIApplication object is to handle the initial routing of incoming user events. It also dispatches action messages forwarded to it by control objects (UIControl) to the appropriate target objects. In addition, the UIApplication object maintains a list of all the windows (UIWindow objects) currently open in the app, so through those it can retrieve any of the app’s UIView objects. The app object is typically assigned a delegate, an object that the app informs of significant runtime events—for example, app launch, low-memory warnings, and app termination—giving it an opportunity to respond appropriately.

UIApplication對象的一個主要角色就是處理將來使用者事件的初始化崩潰。崩潰也會通過合適的目標對象的UIControl對象發送動作資訊給UIApplication對象。另外,UIApplication對象維持著一個當前app所有開啟的所有視窗UIWindow對象的表,所以通過這些它可以取得任意app的UIView對象。app對象通常分配給一個delegate,這個對象是app運行時的重大事件通知,比如說,應用運行,低記憶體警告,應用終止運行,它提供了一個處理的機會。

Apps can cooperatively handle a resource such as an email or an image file through the openURL: method. For example, an app opening an email URL with this method may cause the mail client to launch and display the message.

應用可以通過openURL:方法來協同地處理一個資源,比如一個郵件或者一個圖片檔案。比如說,一個app用這個方法開啟了一個郵件地址可以會使郵件用戶端開啟顯示資訊。

The programmatic interfaces of UIApplication allow you to manage behavior that is specific to the device. Use this object to do the following:

UIApplication介面綱領允許管理硬體明確的行為。使用這個類來進行以下操作。

  • Control the app’s response to changes in interface orientation.

  • 控制app對於改變介面方向的反應
  • Temporarily suspend incoming touch events.

  • 短暫暫停即將發生觸摸事件
  • Turn proximity sensing (of the user’s face) off and on again.

  • 關閉 距離感應器? 和再次開啟
  • Register for remote notifications.

  • 註冊遠程通知
  • Trigger the undo-redo UI (applicationSupportsShakeToEdit).

  • 觸發 取消重做UI
  • Determine whether an installed app can open a URL (canOpenURL:).

  • 決定是否一個已經安裝的app可以開啟某個地址
  • Extend the execution of the app so that it can finish a task in the background.

  • 擴充運行範圍使得app可以在後台完成任務
  • Schedule and cancel local notifications.

  • 安排和取消本地通知
  • Coordinate the reception of remote-control events. 

  • 協調接收遠端控制事件
  • Perform app-level state restoration tasks.

  • 執行app層面的狀態恢複任務

UIApplication defines a delegate that must adopt the UIApplicationDelegate protocol and implement some of the protocol methods.

UIApplication定義了一個必須採用UIApplicationDelegate協議和實現一些協議裡的方法delegate

 

[UIApplication]簡介

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.