applicationWillTerminate:未被调用

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