Is iOS state restoration possible in iOS library? — Could not find a storyboard named

前端 未结 1 1814
挽巷
挽巷 2021-01-21 02:52

I have a library with a storyboard and controller classes that implement iOS state preservation.

To launch the library from the main app\'s delegate, I use the following

相关标签:
1条回答
  • 2021-01-21 03:07

    If the 'libraryMain' is a static library that you link to the main app, then it doesn't contain the storyboard files, and the iOS is missing the file in the main bundle (unless you specifically provide it).

    The reason is that static libraries are archives of the compiled code, and the resources have to be included separately. In this case, you need to find a way to bundle your resources - either including the 'libraryMain' storyboard directly into the main app or creating a "resource" bundle.

    If the 'libraryMain' is a framework with a storyboard file inside, then there are some workarounds.

    The documentation about the state preservation notes that there are two places that iOS checks in order to restore the controller:

    1. viewControllerWithRestorationIdentifierPath:coder: of the restoration class (firstController class, in your question). Here you can create and configure the instance of the first controller
    2. application:viewControllerWithRestorationIdentifierPath:coder: of the app delegate. Here you can create the instance of the class based on the restoration path.

    Both of the options above look like workarounds as I don't have the actual setup of your project to reproduce the problem.

    0 讨论(0)
提交回复
热议问题