application:didFinishLaunchingWithOptions:
UIApplicationDidFinishLaunchingNotification
应用启动并进行初始化时会调用该方法并发出通知。这个阶段会实例化根视图控制器
applicationDidBecomeActive:
UIApplicationDidBecomeActiveNotification
应用进入前台并处于活动状态时调用该方法并发出通知。这个阶段可以恢复UI的状态(例如游戏状态等)
applicationWillResignActive:
UIApplicationWillResignActiveNotification
应用从活动状态进入到非活动状态时调用该方法并发出通知。这个阶段可以保存UI的状态(例如游戏状态等)
applicationDidEnterBackground:
UIApplicationDidEnterBackgroundNotification
应用进入后台时调用该方法并发出通知。这个阶段可以保存用户数据,释放一些资源(例如释放数据库资源等)
applicationWillEnterForeground:
UIApplicationWillEnterForegroundNotification
应用进入到前台,但是还没有处于活动状态时调用该方法并发出通知。这个阶段可以恢复用户数据
applicationWillTerminate:
UIApplicationWillTerminateNotification
应用被终止时调用该方法并发出通知,但内存清除时除外。这个阶段释放一些资源,也可以保存用户数据
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"%@", @"application:didFinishLaunchingWithOptions:");
……
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
NSLog(@"%@", @"applicationWillResignActive:");
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(@"%@", @"applicationDidEnterBackground:");
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
NSLog(@"%@", @"applicationWillEnterForeground:");
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
NSLog(@"%@", @"applicationDidBecomeActive:");
}
- (void)applicationWillTerminate:(UIApplication *)application
{
NSLog(@"%@", @"applicationWillTerminate:");
}
@end
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/wow09_1225/article/details/46806141