ios-AppDelegate經常使用的方法

//UIApplicationDelegate如下的方法都是實現了前面這個協議的
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    //完成應用初始化後須要執行的函數
    NSLog(@"應用初始化完成");
    return YES;
}
                            
- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
   NSLog(@"應用即將進入後臺,意思就是進入後臺失去活動狀態");

}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
      NSLog(@"應用進入後臺,先失去活躍狀態再調用這個");
}

- (void)applicationWillEnterForeground:(UIApplication *)application

{
     NSLog(@"應用即將進入前臺,先進入前臺再到活躍狀態");
    
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
     NSLog(@"應用進入前臺,得到活躍狀態");
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
      NSLog(@"終止函數");//程序關閉的時候被調用
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application{
    //出現內存警告的時候調用
}
相關文章
相關標籤/搜索