2010-07-30 39 views
1

這是一個真正的新手註冊UIApplicationWillTerminateNotification:如何在iOS 4的

使用的是iOS 4 如何在幾個對象註冊?

謝謝!

回答

3

在iOS4中,applicationWillTerminate通常不會爲支持後臺執行的應用程序調用。這可能是你遇到問題的原因。

如果你有殘疾,您可以註冊對象監聽UIApplicationWillTerminateNotification通知,和/或重寫應用程序委託的-applicationWillTerminate:方法,並把你的代碼有:

//set up this class as an observer of UIApplicationWillTerminateNotification 
//so we can intervene when the app is about to exit. 
[[NSNotificationCenter defaultCenter] 
         addObserver:self 
          selector:@selector(applicationWillTerminate:) 
           name:UIApplicationWillTerminateNotification 
           object:[UIApplication sharedApplication]];