IOS開發UI之UIApplicationDelegate協議介紹


#import "AppDelegate.h"編程


@interface AppDelegate ()app


@end ide


@implementation AppDelegate函數


//====================如下方法都是UIApplicationDelegate協議方法========ui


//這個方法是應用程序已經啓動成功後調用this

//這個方法能夠當作IOS應用程序真正的入口spa

//參數一:委託(當前這個應用程序對象).net

//參數二:加載選項3d

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {rest

    //在這個方法裏面實現全部功能(包括數據下載,數據解析和數據顯示)

    NSLog(@"應用程序啓動成功!!!");

    //在這兒實現應用程序的功能.

    

    

    // Override point for customization after application launch.

    return YES;

}



//Resign放棄

//應用程序將要編程非活躍狀態的時候會調用這個方法

//home鍵或者來電

//cmd+shift+h :模擬按home

- (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(@"變成非活躍狀態!");


}


//應用程序進入後臺的時候調用這個方法:home

- (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(@"home鍵進入後臺~");



}

//應用程序將要進入前臺調用這個方法:顯示在界面上

- (void)applicationWillEnterForeground:(UIApplication *)application {

    // 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.

   

    //開啓定時器,遊戲繼續和視頻繼續播放等;

    NSLog(@"將要進入前臺");


}


//應用程序已經變成活躍狀態會調用這個方法(應用程序顯示在界面的那一刻)

- (void)applicationDidBecomeActive:(UIApplication *)application {

    // 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.

    //

    NSLog(@"已經變成活躍狀態~~~");



}


//應用程序將要終止的時候調用這個方法:程序再也不運行;

- (void)applicationWillTerminate:(UIApplication *)application {

    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

    //不讓應用程序在後臺運行

    //設置info.plist文件添加Application does not run in..置爲YES

    NSLog(@"應用程序將要終止!!");


}


@end

相關文章
相關標籤/搜索