UIApplicationDelegate 是最常见的 协议之一
这个协议声明了继承于单例模式下UIApplication对象的委托方法。这些方法提供了有关在应用程序执行时或发生重要变化时进行响应的机会。比如(在应用程序执行时,完成启动时,内存低时……)
Application对象委托方法的主要工作之一就是跟踪应用程序。
对于这些响应,程序员需要按照自己的要求部分或者全部实现
============================================
现在来看看协议里的方法
Monitoring Application State Changes
- (BOOL) application:(UIApplication *) application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions //当应用程序已经启动,并可能有额外的启动选项来处理委托 //强烈建议您使用此方法来初始化你的应用程序,而不是采用 applicationDidFinishLaun ching 方法 这句话是苹果文档里的...applicationDidFinishLaun ching不是亲生的么... ==! - (void)applicationDidBecomeActi ve:(UIApplication *) application //应用程序转入激活状态 - (void)applicationWillResignAct ive:(UIApplication *) application //应用程序转入后台(非激活)状态 - applicationDidEnterBackg round:(UIApplication *) application //应用程序从激活状态转入后台(在 激活与非激活之间?(响应home键)) - applicationWillEnterBack ground:(UIApplication *) application //应用程序从激活状态转入后台(比上一方法先一步....好像没太大差别) - applicationWillTerminate : //应用程序终止时 - applicationDidFinishLaun ching: //应用程序启动
Opening a URL Resource
- (BOOL) application:(UIApplication *) application handleOpenURL:(NSURL *)url //请求委托打开一个 URL资源 - (BOOL) application:(UIApplication *) application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotaion //请求委托打开一个 URL资源
就列举一下了
Managing Status Bar Changes (管理(监听)状态条改变)
-(void) application :(UIApplication *) application willChangeStatusBarOrientation:(UIinterfaceOrientation) newStatusBarOrientation duration:(NSTimeInterval)duration -(void) application :(UIApplication *) application didChangeStatusBarOrient ation:(UIInterfaceOrientation) oldStatusBarOrientation -(void) application :(UIApplication *) application didChangeStatusBarFrame:(CGRect)oldStatusBarFrame -(void) application :(UIApplication *) application willChangeStatusBarFrame :(CGRece)newStatusBraFrame
Responding to System Notifications(响应系统通知)
-applicationDidReceiveMemoryWarning: //当内存低告警时 -applicationSignificantTi meChange: //当系统时间发生显著改变时
Handling Remote Notifications
-(void) application :(UIApplication *) application didReceiveRemoteNotification:(NSDictonary *) userinfo //当一个运行着的应用程序收到一个远程的通知 发送到委托去... -(void) application :(UIApplication *) application didRegisterForRemoteNoti ficationsWithDeviceToken :(NSData *) deviceToken //当一个应用程序成功的注册一个推送服务(APS) 发送到委托去... -(void) application :(UIApplication *) application didFailToRegisterForRemo teNotificationsWithError :(NSError *) error //当 APS无法成功的完成向 程序进程推送时 发送到委托去...
Handling Local Notification (处理本地消息)
-(void) application :(UIApplication *) application didReceiveLocalNotification:(UILocalNotification *)notification //当一个运行着的应用程序收到一个本地的通知 发送到委托去...
Responding to Content Protections Changes(响应受保护内容的改变)
-applicationProtectedDataWillBecomeUnavailable: // 通知委托,受保护的文件当前变为不可用的 -applicationProtectedData WillBecomeAvailable: // 通知委托 受保护的文件当前变为可用