之前用MMDrawerController這個第三方庫,運行的時候會有個警告Warning: Unable to create restoration in progress marker file。
解決方法:
首先看看用于狀態(tài)重建(State restoration)的設(shè)置是不是正確的:
1、在AppDelegate中,重寫application:willFinishLaunching 方法,并return YES。重寫shouldSaveApplicationState 和 shouldRestoreApplicationState方法,都return YES;
2、每一個ViewController(也包括NavigationController和TabBarController)和他們的父視圖控制器都必須設(shè)置 restorationIdentifier屬性;
完成后,運行程序,如果警告還是會出現(xiàn),就按照下面的順序操作來觸發(fā)狀態(tài)保持:
1、在Xcode模擬器上運行程序;
2、在Xcode模擬器上,點擊Home鍵,讓應(yīng)用進入后臺。這時應(yīng)用會調(diào)用encodeRestorableStateWithCoder方法;
3、在Xcode上,點擊stop鍵終止程序;
4、在Xcode上,雙擊Home鍵,在后臺移除應(yīng)用程序;
5、返回Xcode,再次運行程序;
按照這個順序,就沒有警告了。
對于這個警告,我的理解:
不能在進程標(biāo)記文件中創(chuàng)建這個重構(gòu)模型(restoration)。我覺得,如果要這個重構(gòu)模型構(gòu)建成功,程序就要正常的運行一次(包括終止),這樣在以后的運行中,才能夠重用這個重構(gòu)模型。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