[UIApplication]简介

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

 

posted @ 2015-05-31 22:22  baaingSheep  阅读(144)  评论(0编辑  收藏  举报