我需要能够区分应用程序 didFinishLaunching 和应用程序进入后台并被加载回前台。我注意到,如果我注册 UIApplicationDidBecomeActiveNotification,它在两个实例中都会被调用。我如何区分两者?
Best Answer-推荐答案 strong>
使用 didFinishLaunchingWithOptions 与 applicationWillEnterForeground 来区分应用是冷启动还是从后台返回。
我尝试在我的一个应用程序中收听 UINotification,但通知传递得太晚了,所以我求助于直接收听这些方法调用。
- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions
{
// only call when app is freshly launched
}
- (void)applicationWillEnterForegroundUIApplication *)application
{
// Only called when app is returning from background
}
关于iphone - 区分应用程序启动和应用程序唤醒,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/11278725/
|