http://www.csdn123.com/html/blogs/20131016/84091.htm
#pragma mark 在应用程序加载完毕之后调用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"didFinishLaunchingWithOptions-加载完毕");
// 初始化一个窗口
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// 传入xib文件名来初始化一个控制器
self.viewController = [[[MJViewController alloc] initWithNibName:@"MJViewController" bundle:nil] autorelease];
// 设置窗口的根控制器
self.window.rootViewController = self.viewController;
// 上面的代码内部执行了下面代码的操作
// [self.window addSubview:self.viewController.view];
// 窗口不会默认显示,需要调用方法来显示
// keyWindow是主窗口,只有主窗口才能跟用户正常交互
[self.window makeKeyAndVisible];
// self.window.hidden = NO;
return YES;
}
#pragma mark 程序失去焦点的时候调用(不能跟用户进行交互了)
- (void)applicationWillResignActive:(UIApplication *)application
{
NSLog(@"applicationWillResignActive-失去焦点");
}
#pragma mark 当应用程序进入后台的时候调用(点击HOME键)
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(@"applicationDidEnterBackground-进入后台");
}
#pragma mark 当应用程序进入前台的时候调用
- (void)applicationWillEnterForeground:(UIApplication *)application
{
NSLog(@"applicationWillEnterForeground-进入前台");
}
#pragma mark 当应用程序获取焦点的时候调用
// 获取焦点之后才可以跟用户进行交互
- (void)applicationDidBecomeActive:(UIApplication *)application
{
NSLog(@"applicationDidBecomeActive-获取焦点");
}
#pragma mark 程序在某些情况下被终结时会调用这个方法
- (void)applicationWillTerminate:(UIApplication *)application
{
NSLog(@"applicationWillTerminate-被关闭");
}