Fix for setting view controllers twice during state restoration.#260
Fix for setting view controllers twice during state restoration.#260AndriyGo wants to merge 1 commit intomutualmobile:masterfrom AndriyGo:master
Conversation
Introduced changes in the decodeRestorableStateWithCoder method so that during state restoration left/center/right controllers are not reassigned if they are already assigned by user
|
Just now getting around to this. I'm actually a bit concerned with this PR. If the drawer controllers and center controller are not nil, why would we even be in this method. I'm wondering if there is potentially a bug elsewhere. |
|
I am not sure that this is a bug. In my app I am assigning the MMDrawerController as the rootViewController in willFinishLaunchinWithOptions:. I am also creating the left controller (which is a menu and doesn't change) and a centre controller (which is a UINavigationController). I then have a method viewControllerWithRestorationIdentifierPath: where I do return the MMDrawerController and other created controllers for the appropriate restorationIdentifier keys. So, the fact that decodeRestorableStateWithCoder: is called on MMDrawerController seems to me like a correct behaviour (after all I do want it to restore the open state of the drawer and other things). Basically, I have the same behaviour as in KitchenSink where controllers are also created and then returned in the viewControllerWithRestorationIdentifierPath: . And it looks like being in the decodeRestorableStateWithCoder: on MMDrawerController is correct in this case. Either we shouldn't be restoring child controllers in decodeRestorableStateWithCoder: or we should not be creating those controllers ourselves. I don't remember if I tried the later approach to confirm that it works or not. |
Introduced changes in the decodeRestorableStateWithCoder method so that during state restoration left/center/right controllers are not reassigned if they are already assigned by user