ios - 强制应用程序在进入后台时始终采用相同的形式

标签 ios objective-c background

我正在开发一个具有多种形式的应用程序,用户可能处于这些形式中的任何一种,并决定将应用程序转到后台。 如何强制应用程序在进入后台时始终保持相同的形式?

为了避免疑义,我试着用例子来更好地解释: 我的应用程序中有 45 个 View 。用户可以在 View 1、2、3、4 上......但是当他将应用程序置于后台时,我想立即转到 View 9。 谢谢。

最佳答案

您应该实现 State Preservation and Restoration在您的应用中。

The state preservation system in UIKit provides a simple but flexible infrastructure for preserving and restoring the state of your app’s view controllers and views.

The job of the infrastructure is to drive the preservation and restoration processes at the appropriate times. To do that, UIKit needs help from your app. Only you understand the content of your app, and so only you can write the code needed to save and restore that content.

And when you update your app’s UI, only you know how to map older preserved content to the newer objects in your interface.

您必须在三个地方考虑​​应用中的状态保存:

  • 您的应用委托(delegate)对象,它管理应用的顶级状态
  • 您应用的 View Controller 对象,用于管理应用用户界面的整体状态
  • 您应用的自定义 View ,其中可能包含一些需要保留的自定义数据

调查:

关于ios - 强制应用程序在进入后台时始终采用相同的形式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25061278/

相关文章:

c++ - 代码 : How to address dynamic Variables?

android - (Android) 如何填充 ListView 背景并保持标题透明度

css - 将背景放在div之外

iphone - 更改 CGContext 的背景颜色

ios - 在App Purchase中可以正常使用,但是付款成功后我无法更改UIButton图像

iOS GPS 跟踪应用程序在后台关闭

ios - 动画化 UITextInput 的 textInputView

ios - 加载 UIImage 并删除原始文件

ios - Facebook 登录按钮抛出错误并显示我无法登录

iphone - 未调用 UITextView textViewShouldEndEditing/textViewDidEndEditing