我需要能够区分应用程序 didFinishLaunching 和应用程序进入后台并加载回前台。我注意到,如果我注册 UIApplicationDidBecomeActiveNotification,它在两个实例中都会被调用。我如何区分两者?
问问题
920 次
2 回答
4
使用didFinishLaunchingWithOptions
vsapplicationWillEnterForeground
来区分应用是冷启动还是从后台返回。
我尝试在我的一个应用程序中收听 UINotification,但通知传递得太晚了,所以我采取了直接收听这些方法调用的方法。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// only call when app is freshly launched
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Only called when app is returning from background
}
于 2012-07-01T00:44:24.107 回答
0
我需要能够区分应用程序 didFinishLaunching
UIApplicationDidFinishLaunchingNotification
应用进入后台
UIApplicationDidEnterBackgroundNotification
被加载回前台
UIApplicationWillEnterForegroundNotification
于 2012-07-01T00:44:34.873 回答