本文介绍了没有得到didReceiveMemoryWarn当应用程序在后台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到我的视图控制器没有得到他们的 didReceiveMemoryWarning 方法调用时,我的应用程序在iPad模拟器的后台状态。更具体地说,我看到在我的日志中调用 applicationDidEnterBackground ,然后我点击模拟内存警告按钮,然后我注意到一个特别缺乏任何 didReceiveMemoryWarning 调用。

I'm noticing that my view controllers aren't getting their didReceiveMemoryWarning methods called when my application is in the background state on the iPad simulator. More specifically, I see the call to applicationDidEnterBackground in my logs, then I hit the "Simulate Memory Warning" button, and then I notice a peculiar lack of any didReceiveMemoryWarning calls.

然而,当我把应用程序恢复到前台时,突然得到 didReceiveMemoryWarning 调用,好像它已经排队了。

However, when I bring the application back to the foreground I suddenly get the didReceiveMemoryWarning call, as if it had been queued.

我困惑的是,如果我的应用程序真的在后台,只是平了暂停。在模拟器中有什么方法可以告诉吗?

What I'm confused about here is if my application is really in the background, or if it's just flat out suspended. Is there any way to tell in the simulator?

此外,如果它还没有挂起,真的只是在后台,那么我会发现无法处理 didReceiveMemoryWarning 。因为这将意味着只有前台应用程序可以处理内存警告以释放空间,这当然是奇怪的,因为前台应用程序可能只有几十个运行的应用程序之一,如果他们可以释放内存。

Also, if it is not yet suspended, and really is just in the background, then I would find it silly that I'm unable to process didReceiveMemoryWarning. Because that would then mean that only the foreground application can process memory warnings to free up space, which is of course odd given that the foreground app could be only one of possibly dozens of running apps, and it would make so much more sense if they could all free up memory.

无论如何,主要的问题是:为什么我不会在 didReceiveMemoryWarning 背景状态?而且,我真的暂停了吗?

Anyway, the main questions are: why aren't I getting didReceiveMemoryWarning in the background state? And also, am I really suspended? And how do I tell?

推荐答案

如果您没有开始执行后台任务,或者执行VOIP,位置跟踪或音频背景,那么您的应用程序在applicationDidEnterBackground后暂停。它不会收到任何通知。任何通知都会保留(即使是在应用程式被暂停后发生的),并在应用程式再次前往前台时传送到应用程式。

If you did not start a background task, or do VOIP, location tracking or audio in the background, then your app is suspended after applicationDidEnterBackground. It will not get any notifications. Any notifications are kept around (even those that occur after the app was suspended) and sent to the app when the app goes to the foreground again.

这篇关于没有得到didReceiveMemoryWarn当应用程序在后台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 00:01