我需要確定傳入的電話呼叫何時到達。我知道,如果用戶接聽電話時會調用applicationWillTerminate,並在出現帶有確認消息的彈出窗口時顯示applicationWillResignActive,但是:
-applicationWillTerminate也會在應用程序退出用戶請求或電池即將死亡時調用
-applicationWillResignActive在顯示UIViewAlert時也被調用。檢測傳入的電話呼叫
感謝
我需要確定傳入的電話呼叫何時到達。我知道,如果用戶接聽電話時會調用applicationWillTerminate,並在出現帶有確認消息的彈出窗口時顯示applicationWillResignActive,但是:
-applicationWillTerminate也會在應用程序退出用戶請求或電池即將死亡時調用
-applicationWillResignActive在顯示UIViewAlert時也被調用。檢測傳入的電話呼叫
感謝
簡而言之 - 不,你不能確定是否有來電或應用程序中的另一種中斷。
我怕的就是這個。不管怎麼說,多謝拉。 – 2009-11-16 13:56:45
看起來'CoreTelephony'可能有一個方法:http://stackoverflow.com/questions/18310332/detecting-the-call-events-in-ios – 2014-08-21 16:20:40
我在處理來電時發現了這篇文章;終止恢復和堅持狀態。
它可以幫助你..
http://www.tomwhitson.co.uk/blog/2009/04/handling-interuptions-to-your-app/
(void)applicationWillResignActive:(UIApplication *)application{
//our app is going to loose focus since thier is an incoming call
[self pauseGame];
}
(void)applicationDidBecomeActive:(UIApplication *)application{
//the user declined the call and is returning to our app
[self resumeGame];
}
(void)applicationWillTerminate:(UIApplication*)application{
//the user answered the call (or quit the app) so save the
//game as we are shutting down
[self saveGameState];
}
這對很多場景很有用,但是你不能100%確定applicationWillResignActive是稱爲來電打電話的結果。 – 2009-11-16 14:31:23
我知道這個問題是真的老了,但萬一別人達到這個問題和我一樣,有一個音頻會議委託檢測如果音頻將被中斷(主要通過電話呼叫)。
對於任何播放音頻的應用程序,此方法適用於檢測傳入的iPhone呼叫。
這裏是蘋果文檔的鏈接爲:Handling Audio Interruptions
請參閱http://stackoverflow.com/questions/3319805/detecting-call-state-in-ios4 – 2012-06-15 13:14:12