Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

State Restoration with Multiple Storyboards

I am working on a project with multiple storyboards. I want to implement state restoration in this project. I am having a problem linking the ViewControllers on second storyboard into the state restoration process.

encodeRestorableStateWithCoder: & decodeRestorableStateWithCoder: methods are invoked only for ViewControllers associated with the Main storyboard.

How do you link the ViewControllers in the second storyboard to the state restoration process?

like image 592
jpsasi Avatar asked Sep 27 '14 17:09

jpsasi


People also ask

Can we use multiple storyboards in one application?

A storyboard is meant to explain a story, not a saga. An app's storyboard can be easily divided into multiple storyboards, with each one representing an individual story.

How can we restore app state and its data?

Restore the App State Using View Controllers This sample preserves its state by saving the state of its view controller hierarchy. View controllers adopt the UIStateRestoring protocol, which defines methods for saving custom state information to an archive and restoring that information later.


1 Answers

When you load a class from the other storyboard you essentially need to start using the manual approach to state restoration. (aka Restoration Classes)

This means that the view controller you loaded on the second storyboard must have a restoration ID assigned and implement the UIViewControllerRestoration protocol.

like image 87
kvn Avatar answered Oct 25 '22 21:10

kvn