ecomeActive中确定它是否是最初的iPhone应用程序启

ecomeActive中确定它是否是最初的iPhone应用程序启

本文介绍了如何在applicationDidBecomeActive中确定它是否是最初的iPhone应用程序启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定如何在UIApplicationDidBecomeActiveNotification中确定它是否是初始应用程序启动?是否是初始应用程序启动?

how to determine in how to determine in UIApplicationDidBecomeActiveNotification whether it is the initial app launch?whether it is the initial app launch?

这是初始启动时间应用程序,而不是后续的DidBecomeActive,因为应用程序被放在后台然后到前台(例如用户转到日历然后回到你的应用程序)

that is the initial start up of the application, as opposed to subsequent DidBecomeActive's due to the application being put in background and then to foreground (e.g. user goes to calendar then back to your app)

推荐答案

在你的 applicationDidFinishLaunching:withOptions:把这个:

[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"alreadyLaunched"];
[[NSUserDefaults standardUserDefaults] synchronize];

然后,在 didBecomeActive

if ([[NSUserDefaults standardUserDefaults] boolForKey:@"alreadyLaunched"]) {
    // is NOT initial launch...
} else {
    // is initial launch...
}

这篇关于如何在applicationDidBecomeActive中确定它是否是最初的iPhone应用程序启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 01:32