我需要确定来电时间何时到来。我知道,如果用户接听电话时将调用applicationWillTerminate,并且当弹出时显示呼叫确认消息时,将调用applicationWillResignActive: 当应用程序按用户请求退出或电池即将耗尽时,也会调用-applicationWillTerminate 当显示UIViewAlert时,也会调用-applicationWillResignActive。
由于
答案 0 :(得分:5)
简而言之 - 不,您无法确定应用中是否有来电或其他类型的中断。
答案 1 :(得分:4)
我发现这篇关于处理来电的文章;终止恢复和持久状态,。
它可能对你有所帮助..
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];
}
答案 2 :(得分:3)
我知道这些问题确实很旧,但是如果其他人像我一样接触到这个问题,会有一个音频会话代表来检测音频是否会被中断(主要是通过电话)。
对于任何播放音频的应用,此方法适用于检测拨入的iphone电话。
以下是Apple文档的链接:Handling Audio Interruptions