applicationWillTerminate:未被调用 [英] applicationWillTerminate: not being called

查看:641
本文介绍了applicationWillTerminate:未被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 applicationWillTerminate:来保存最后一分钟的内容。但问题是它从来没有被调用。如果我在方法的顶部做这样的事情: NSLog(@Something); 它不会被调用,不会输出到控制台。

I'm using applicationWillTerminate: to save some last-minute stuff. But the problem is that it never gets called. If I do something like this at the top of the method: NSLog(@"Something"); it doesn't get called and doesn't get outputted to the console.

有人知道为什么会发生这种情况吗?

Does anyone know why this is happening?

推荐答案

docs:

对于不支持后台执行或与iOS 3.x或更早版本链接的应用程序,当用户退出应用程序时,将始终调用此方法。 对于支持后台执行的应用程序,当用户退出应用程序时,此方法通常不会调用,因为在这种情况下应用程序只会移动到背景。但是,在应用程序在后台运行(未暂停)并且系统由于某种原因需要终止该应用程序的情况下,可能会调用此方法。

For applications that do not support background execution or are linked against iOS 3.x or earlier, this method is always called when the user quits the application. For applications that support background execution, this method is generally not called when the user quits the application because the application simply moves to the background in that case. However, this method may be called in situations where the application is running in the background (not suspended) and the system needs to terminate it for some reason.

如果您的应用程序已启用背景:

If your app has background enabled use:

- (void)applicationDidEnterBackground:(UIApplication *)application

这篇关于applicationWillTerminate:未被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆