回答
我相信,你應該通過以下方法一次。
- (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.
*/
}
- (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.
*/
}
你放在applicationWillTerminate
的代碼,把它放在上面提到的方法..
嘗試把你的代碼的方法之一&檢查你的邏輯工作與否。
編輯:
你質疑規定,要檢測的應用程序強制退出事件 - 這是不可能的。 (抱歉,但不能在我手中)
我們通過雙擊從最小化狀態刪除應用程序的方式 - 這實際上意味着,我們力在quiting這些應用&這不會引發任何的我們的應用程序的方法爲我們的應用程序是將會被殺死。
當你說關閉你的意思是:當一個應用程序從最近使用的欄(雙按home鍵)關閉。
當用戶關閉你的應用程序時,你無法檢測到,因爲操作系統只會殺死你的應用程序。這不是封閉的,並且正在調用close方法。
謝謝,你確定在這種情況下該方法不被稱爲? – damacri86 2012-01-30 12:44:49
當您按Home按鈕時,應用程序不會退出/退出。它只是進入背景。所以applicationWillTerminate沒有被調用。
按主頁按鈕兩次以驗證應用程序是否關閉。
還猜測星火的答案
是的我知道,但是我想要在關閉應用程序時按下主頁按鈕兩次 – damacri86 2012-01-30 12:45:24
- 1. 如何知道何時關閉我的應用程序?
- 2. 如何知道用戶何時關閉了Android應用程序?
- 3. 如何知道用戶何時關閉了Web應用程序
- 4. 我如何知道我的應用程序正在關閉?
- 5. 如何在特定時間關閉通知,即使應用程序已關閉
- 6. 如何知道應用程序正在關閉
- 7. 需要知道應用程序何時關閉
- 8. 有沒有人知道應用程序審查過程關閉的時間?
- 9. 如何知道使用python打開的應用程序何時關閉?
- 10. Android,我如何知道應用程序是否已關閉
- 11. 如何知道Delphi應用程序未正確關閉?
- 12. 如何知道手機應用程序是否關閉
- 13. 如何知道用戶何時關閉瀏覽器?聊天應用程序
- 14. 如何在Windows中關閉應用程序時間表?
- 15. 關閉應用程序的時間
- 16. 當應用程序關閉時關閉另一個進程
- 17. 如何在應用程序關閉時顯示通知(iOS)?
- 18. 如何在應用程序關閉時發送通知?
- 19. 如何在應用程序關閉時接收推送通知?
- 20. 如何在應用程序關閉時發送推送通知?
- 21. 如何在應用程序關閉時管理時間?
- 22. 如何在應用程序關閉時閱讀我應用程序中的所有應用程序通知?
- 23. 如何在android中關閉應用程序時使用某些時間間隔?
- 24. 如何知道服務器(tomcat6)在JSF 1.2應用程序中關閉
- 25. 如何知道應用何時被用戶強制關閉?
- 26. 如何知道wxFrame何時關閉?
- 27. 如何從VB.NET中的應用程序中關閉另一個應用程序?
- 28. 如何在窗口關閉時關閉JavaFX應用程序?
- 29. 如何知道應用程序的加載時間?
- 30. 音板應用程序的力量關閉,我不知道爲什麼
'從跳板關閉'?意味着,你想捕獲從後臺運行的應用程序關閉應用程序? – Ilanchezhian 2012-01-30 12:31:56