[英]state restoration in iOS
I am storing my application screen, so that when the application gets opened it will show the screen that was stored. 我正在存储我的应用程序屏幕,以便在应用程序打开时它将显示已存储的屏幕。 The application is navigation based.
该应用程序是基于导航的。
I have assigned the Restoration Ids to my two view controllers in main story board. 我已将Restoration Ids分配给主故事板中的两个视图控制器。 The first controller is the root view controller of the navigation controller.
第一个控制器是导航控制器的根视图控制器。 I have also assigned Restoration Id to the navigation controller.
我还为导航控制器分配了Restoration Id。 Now the problem is when I run the application I am getting the following warning:
现在问题是当我运行应用程序时,我收到以下警告:
Unable to create restoration in progress marker file.
无法创建正在进行的恢复标记文件。
Not sure what else need to be done. 不确定还需要做什么。
I had the same warning before and fixed it by doing the followings. 之前我有同样的警告并通过以下方式修复它。
I was using storyboard. 我在使用故事板。 My storyboard only included a navigation view controller and a view controller (which was the root view controller of that navigation view controller).
我的故事板只包括导航视图控制器和视图控制器(该导航视图控制器的根视图控制器)。 In my case, it was caused by either of the two reasons:
在我的情况下,它是由两个原因之一引起的:
The application was not set up correctly for state preservation The followings need to be set: 未正确设置应用程序以进行状态保存需要设置以下内容:
In app delegate, override application:willFinishLaunching. 在app delegate中,覆盖应用程序:willFinishLaunching。 One can simply return YES in that method.
可以在该方法中简单地返回YES。
For every view controllers and views (including the navigation view controllers and tab view controllers), set a restore ID 对于每个视图控制器和视图(包括导航视图控制器和选项卡视图控制器),请设置还原ID
In app delegate, opt-in by overriding shouldSaveApplicationState
and shouldRestoreApplicationState
在app delegate中,通过覆盖
shouldSaveApplicationState
和shouldRestoreApplicationState
选择加入
If this warning still occurred, you could check how you run your app in Xcode. 如果仍然出现此警告,您可以检查在Xcode中如何运行应用程序。 I ran my app in Xcode simulator and had to follow a specific sequence to trigger state preservation.
我在Xcode模拟器中运行我的应用程序,并且必须遵循特定的顺序来触发状态保存。
encodeRestorableStateWithCoder
method of the view controller should be called encodeRestorableStateWithCoder
方法 That warning should not appear. 不应该出现这个警告。 When I used other sequences, I saw that warning appearing.
当我使用其他序列时,我看到出现了警告。 When I debugged my app on my device using Xcode, I followed the same sequence and did not see the warning.
当我使用Xcode在我的设备上调试我的应用程序时,我按照相同的顺序,没有看到警告。
I think that warning indicated that because Xcode could not terminate the app correctly, the state restoration file was not correctly saved onto the disk. 我认为该警告表明,由于Xcode无法正确终止应用程序,因此状态恢复文件未正确保存到磁盘上。
Try to give your View a restoration ID. 尝试为您的View提供恢复ID。 You can do so to open your xib or storyboard and assign the id to your View Controller.
您可以这样做以打开xib或故事板并将ID分配给View Controller。
more details: http://useyourloaf.com/blog/2013/05/21/state-preservation-and-restoration.html 更多详情: http : //useyourloaf.com/blog/2013/05/21/state-preservation-and-restoration.html
Try running on the device. 尝试在设备上运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.