美文网首页
State restoration 状态重建时遇到的问题War

State restoration 状态重建时遇到的问题War

作者: 大风天上来 | 来源:发表于2016-09-27 20:47 被阅读253次

    之前用MMDrawerController这个第三方库,运行的时候会有个警告Warning: Unable to create restoration in progress marker file。

    解决方法:

    首先看看用于状态重建(State restoration)的设置是不是正确的:

    1、在AppDelegate中,重写application:willFinishLaunching 方法,并return YES。重写shouldSaveApplicationState 和 shouldRestoreApplicationState方法,都return YES;

    2、每一个ViewController(也包括NavigationController和TabBarController)和他们的父视图控制器都必须设置 restorationIdentifier属性;

    完成后,运行程序,如果警告还是会出现,就按照下面的顺序操作来触发状态保持:

    1、在Xcode模拟器上运行程序;

    2、在Xcode模拟器上,点击Home键,让应用进入后台。这时应用会调用encodeRestorableStateWithCoder方法;

    3、在Xcode上,点击stop键终止程序;

    4、在Xcode上,双击Home键,在后台移除应用程序;5、返回Xcode,再次运行程序;

    按照这个顺序,就没有警告了。

    这个警告是说:不能在进程标记文件中创建这个重构模型(restoration)。我觉得,如果要这个重构模型构建成功,程序就要正常的运行一次(包括终止),这样在以后的运行中,才能够重用这个重构模型。Xcode的stop并不是正常的终止了程序。参考:

    http://stackoverflow.com/questions/19424670/state-restoration-in-ios?rq=1

    http://stackoverflow.com/questions/18932156/cryptic-warning-without-any-google-results-in-simulator

    相关文章

      网友评论

          本文标题: State restoration 状态重建时遇到的问题War

          本文链接:https://www.haomeiwen.com/subject/ijodkttx.html