iphone - 区分应用程序启动和应用程序唤醒
<p><p>我需要能够区分应用程序 didFinishLaunching 和应用程序进入后台并被加载回前台。我注意到,如果我注册 UIApplicationDidBecomeActiveNotification,它在两个实例中都会被调用。我如何区分两者? </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>使用 <code>didFinishLaunchingWithOptions</code> 与 <code>applicationWillEnterForeground</code> 来区分应用是冷启动还是从后台返回。</p>
<p>我尝试在我的一个应用程序中收听 UINotification,但通知传递得太晚了,所以我求助于直接收听这些方法调用。</p>
<pre><code>- (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
}
</code></pre></p>
<p style="font-size: 20px;">关于iphone - 区分应用程序启动和应用程序唤醒,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/11278725/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/11278725/
</a>
</p>
页:
[1]