IOS AppDelegate.m 詳解

來源:互聯網
上載者:User

今天在學習 IOS 中 Storyboard 的使用中,操作都是沒問題的,就是啟動後一直出現的是 白色 介面,不能進行跳轉操作。找了好久也沒找到方法,最後,問了老大,發現了問題所在,原來是 AppDelegate.m 檔案中的, 該注釋掉的沒注釋掉 :

 

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    //self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    //Override point for customization after application launch.    //self.window.backgroundColor = [UIColor whiteColor];    //[self.window makeKeyAndVisible];    return YES;}
 因為之前一直對 IOS 中的  AppDelegate.m 不太瞭解,才會導致這個問題,所以這次一定要徹底的搞明白  AppDelegate.m  這個重要的檔案,這將極大的協助你瞭解 Xcode 中 IOS 的開發~ 關於 AppDelegate,有一個國外的使用者,總結的特別好: AppDelegate.h/m define a class that manages the application overall. The app will create one instance of that class and send that object messages that let the delegate influence the app's behavior at well-defined times. For example, -application:didFinishLaunchingWithOptions: is sent when the app has finished launching and is ready to do something interesting. Take a look at the UIApplicationDelegate reference page for a list of messages that the app delegate can implement to modify the behavior of the application. 看到了吧,如果通過上面的解釋,可以看出來,AppDelegate.h/m 是一個很重要的檔案,如果你做過 Asp.Net 開發,那麼這個檔案就類似於 .Net 中的 Global.ascx 檔案,就是做一些全域變數的控制的。  本文禁止任何網站轉載,嚴厲譴責那些蛀蟲們。
本文首發於,部落格園,請搜尋:部落格園 - 尋自己,查看原版文章
本文首發地址:IOS AppDelegate.m 詳解 - www.cnblogs.com/xunziji/archive/2012/09/17/2689184.html 下面就過一下,AppDelegate.h/m 中預設的方法:  1. application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions Tells the delegate when the application has launched and may have additional launch options to handle. 在應用程式啟動後,要執行的委託調用。   2. applicationWillResignActive:(UIApplication *)application Tells the delegate that the application is about to become inactive.This method is called to let your application know that it is about to move from the active to inactive state.After calling this method, the application also posts a UIApplicationWillResignActiveNotification notification to give interested objects a chance to respond to the transition. 在應用程式將要由活動狀態切換到非使用中時候,要執行的委託調用,如 按下 home 按鈕,返回主畫面,或全屏之間切換應用程式等。   本文禁止任何網站轉載,嚴厲譴責那些蛀蟲們。
本文首發於,部落格園,請搜尋:部落格園 - 尋自己,查看原版文章
本文首發地址:IOS AppDelegate.m 詳解 - www.cnblogs.com/xunziji/archive/2012/09/17/2689184.html 3. applicationDidEnterBackground:(UIApplication *)application Tells the delegate that the application is now in the background.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. 在應用程式已進入背景程式時,要執行的委託調用。   4. applicationWillEnterForeground:(UIApplication *)application Tells the delegate that the application is about to enter the foreground.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. 在應用程式將要進入前台時(被啟用),要執行的委託調用,剛好與 applicationWillResignActive 方法相對應。   5. applicationDidBecomeActive:(UIApplication *)application Tells the delegate that the application has become active.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. 在應用程式已被啟用後,要執行的委託調用,剛好與  applicationDidEnterBackground 方法相對應。  6. applicationWillTerminate:(UIApplication *)application Tells the delegate when the application is about to terminate.Called when the application is about to terminate. Save data if appropriate.  本文禁止任何網站轉載,嚴厲譴責那些蛀蟲們。
本文首發於,部落格園,請搜尋:部落格園 - 尋自己,查看原版文章
本文首發地址:IOS AppDelegate.m 詳解 - www.cnblogs.com/xunziji/archive/2012/09/17/2689184.html在應用程式要完全推出的時候,要執行的委託調用。  有沒有發現,IOS 中的 AppDelegate.m/h 檔案是很重要的呢,因為它是對 Application 的整個生命週期進行管理的,有木有~  本文禁止任何網站轉載,嚴厲譴責那些蛀蟲們。
本文首發於,部落格園,請搜尋:部落格園 - 尋自己,查看原版文章
本文首發地址:IOS AppDelegate.m 詳解 - www.cnblogs.com/xunziji/archive/2012/09/17/2689184.html 
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.