#pragma mark在應(yīng)用程序加載完畢之后調(diào)用
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
NSLog(@"didFinishLaunchingWithOptions-加載完畢");
//初始化一個(gè)窗口
self.window= [[[UIWindowalloc]initWithFrame:[[UIScreenmainScreen]bounds]]autorelease];
//傳入xib文件名來初始化一個(gè)控制器
self.viewController= [[[MJViewControlleralloc]initWithNibName:@"MJViewController"bundle:nil]autorelease];
//設(shè)置窗口的根控制器
self.window.rootViewController=self.viewController;
//上面的代碼內(nèi)部執(zhí)行了下面代碼的操作
// [self.window addSubview:self.viewController.view];
//窗口不會(huì)默認(rèn)顯示闯传,需要調(diào)用方法來顯示
// keyWindow是主窗口令境,只有主窗口才能跟用戶正常交互
[self.windowmakeKeyAndVisible];
// self.window.hidden = NO;
returnYES;
}
#pragma mark程序失去焦點(diǎn)的時(shí)候調(diào)用(不能跟用戶進(jìn)行交互了)
- (void)applicationWillResignActive:(UIApplication*)application
{
NSLog(@"applicationWillResignActive-失去焦點(diǎn)");
}
#pragma mark當(dāng)應(yīng)用程序進(jìn)入后臺(tái)的時(shí)候調(diào)用(點(diǎn)擊HOME鍵)
- (void)applicationDidEnterBackground:(UIApplication*)application
{
NSLog(@"applicationDidEnterBackground-進(jìn)入后臺(tái)");
}
#pragma mark當(dāng)應(yīng)用程序進(jìn)入前臺(tái)的時(shí)候調(diào)用
- (void)applicationWillEnterForeground:(UIApplication*)application
{
NSLog(@"applicationWillEnterForeground-進(jìn)入前臺(tái)");
}
#pragma mark當(dāng)應(yīng)用程序獲取焦點(diǎn)的時(shí)候調(diào)用
//獲取焦點(diǎn)之后才可以跟用戶進(jìn)行交互
- (void)applicationDidBecomeActive:(UIApplication*)application
{
NSLog(@"applicationDidBecomeActive-獲取焦點(diǎn)");
}
#pragma mark程序在某些情況下被終結(jié)時(shí)會(huì)調(diào)用這個(gè)方法
- (void)applicationWillTerminate:(UIApplication*)application
{
NSLog(@"applicationWillTerminate-被關(guān)閉");
}
項(xiàng)目啟動(dòng)后:
第一個(gè)iOS程序[517:c07]
didFinishLaunchingWithOptions-加載完畢
第一個(gè)iOS程序[517:c07]
applicationDidBecomeActive-獲取焦點(diǎn)
按下home鍵:
第一個(gè)iOS程序[517:c07]
applicationWillResignActive-失去焦點(diǎn)
第一個(gè)iOS程序[517:c07]
applicationDidEnterBackground-進(jìn)入后臺(tái)
再按程序:
第一個(gè)iOS程序[517:c07]
applicationWillEnterForeground-進(jìn)入前臺(tái)
第一個(gè)iOS程序[517:c07]
applicationDidBecomeActive-獲取焦點(diǎn)