background - 后台状态与已暂停的应用程序状态之间的混淆

标签 background ios5 uiapplication application-state

我对这两种状态感到困惑。以下是我的理解;

when app is in background and if you have "Application does not run in background" set to NO in App plist file then App continues running in background. In suspend mode App stays in memory but does not execute code! System doesn't notify App when it moves to Suspended state and wipes out App from memory in low memory situation to create space for foreground Apps.



我的理解正确吗?如果是这样,那么当应用程序在后台运行并执行代码时,为什么不将NSLog打印在控制台上?我不断从服务器获取数据的TCP套接字连接实际上发生了什么?为什么我们需要挂起状态,因为无论如何,系统最终会在内存不足的情况下从内存中清除App。从暂停状态变为事件状态或从全新状态开始运行之间有什么区别吗?

最佳答案

您应该在IOS App编程指南的“应用程序状态和多任务”部分中查找。
通过将词组“应用程序状态和多任务”和“必须满足”项设置为“匹配搜索词”来搜索Xcode文档。另一个有用的搜索词:“后台执行”。
总结的答案是,应用程序可以仅出于有限的原因无限期地在后台继续“执行”:

in iOS, only specific app types are allowed to run in the background:

  • Apps that play audible content to the user while in the background, such as a music player app
  • Apps that keep users informed of their location at all times, such as a navigation app
  • Apps that support Voice over Internet Protocol (VoIP)
  • Newsstand apps that need to download and process new content
  • Apps that receive regular updates from external accessories

除了这些特定的操作,应用程序可能会要求在很短的时间内继续执行,该文档在“在后台执行有限长度的任务”一节中介绍了。短时间后,您的应用程序会告诉系统它已完成(然后挂起)或被强制终止。文档中的详细信息。
该文档的另一个有用的部分是精美的状态图,它是“管理应用程序状态更改”部分。该部分讨论进入后台并返回到前台。它应该回答您有关从重新开始状态与从暂停状态开始之间的区别的问题。简短(不太正确)的答案是,如果您从暂停状态开始,并且在进入背景或(重新)进入前景时未执行任何特殊操作,那么您只会或多或少地从原来的位置继续。同样,从挂起状态开始更快。请阅读该文档,因为它说的比我的释义要好得多。

关于background - 后台状态与已暂停的应用程序状态之间的混淆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15086619/

相关文章:

caching - CSS 背景图片间歇性地出现在谷歌浏览器中

html - CSS背景图片的位置?

ios5 - 每个 Twitter API 请求都必须存在于 ACAccount 请求中吗?

ipad - 在 iOS 6.0 中设置状态栏方向

iOS 9 UIApplicationDidBecomeActiveNotification 回调未调用

当手机处于 sleep 模式时,iOS BLE 在后台扫描广告数据

Android:ListView 项目中的平铺位图

objective-c - iOS:UIView 的简单物理

ios - CGAffineTransformMakeRotation(M_PI_2) 在控制台 : CGAffineTransformInvert: singular matrix 中生成错误

ios - 将图像从 ios 应用程序上传到服务器