iphone - 如何区分打电话后重新启动的应用程序和从跳板启动的应用程序?

标签 iphone objective-c ios cocoa-touch

我希望我的应用程序具有不同的功能,具体取决于它是否在后台仍处于事件状态(即未完全退出)时启动,以及在电话调用后重新启动时启动。可能吗?

我在 stackoverflow 上找到的答案大多与如何在通话后恢复有关。

编辑:我在 2008 年的苹果论坛上找到了这个问题的答案,其中涉及根据您的平均通话时间进行扣除,看起来这仍然是最有效的选择?

最佳答案

在您的应用程序委托(delegate)中,有两种方法将在您的应用程序运行时被调用,例如接到电话时:

- (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)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

如果您的应用程序在后台运行或在通话开始时未运行,则肯定无法判断是否已调用电话。

关于iphone - 如何区分打电话后重新启动的应用程序和从跳板启动的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11307322/

相关文章:

iphone - NSDictionary 上是否有一个开源类别可以快速将其从 NSData 转换为/转换为 NSData?

iphone - 在应用程序商店中打开 itune 链接?

iphone - 录制音频并保存到文档目录后无法使用 AVAudioPlayer 播放音频文件

ios - AWS iOS Cognito - 如何检查用户池中的用户?

iphone - NSMutableString stringByReplacingOccurrencesOfString 警告

iphone - 控制台错误 : failed to find PDF header: `%PDF' not found

ios - 如何为自动布局创建自定义类?

ios - Iphone, iPad 屏幕尺寸以编程方式纵向和横向模式

objective-c - 如何激活没有标题栏的窗口

ios - 快速 iOS 本地通知