2010-10-06 33 views
-1

當我的應用程序application..but退出該功能會自動調用此函數不能自動applicationDidEnterBackground

+0

在iOS系統4.0和更高版本,該方法被調用,而不是applicationWillTerminate:方法時用戶退出支持後臺執行的應用程序。請參閱http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html以獲取更多信息 – AlexVogel 2010-10-06 11:57:56

回答

11

調用此方法僅稱爲ApplicationDelegate實例,以便爲這你把你的代碼?

如果您需要在ApplicationDelegate之外進入背景時收到通知,您可以註冊NSNotificationCenter

[[NSNotificationCenter defaultCenter] addObserver: whatever 
    selector: @selector(enteredBackground:) 
    name: UIApplicationDidEnterBackgroundNotification 
    object: nil]; 

這將在任何一類的工作,但你顯然需要創建方法enteredBackground或者無論你怎麼稱呼它:)

+0

sir我們如何在iPhone – sidhu 2010-10-06 12:04:21

+0

中啓用多任務處理您可以在應用程序plist – willcodejavaforfood 2010-10-06 12:13:59

+0

但除非您禁用多任務處理,否則將默認啓用。不過你確實需要iOS4 – willcodejavaforfood 2010-10-06 12:15:27

相關問題