Search code examples
iosswiftios8state-restoration

After state restoration, dismissViewControllerAnimated is not using the same animation


I'm implementing an iOS app using storyboards where a button calls dismissViewControllerAnimated to move back from a view controller B to the previous view controller A.

Between the two controllers, I've set a modal segue using an horizontal flip animation:

View Controller A → (Modal Segue with Flip transition) → View Controller B

Tapping the button, the dismissViewControllerAnimated executes the Flip transition reversed, as expected.

But when the app is using the state restoration mechanism to display the controller B, the transition used is the standard one (the view is popped out) instead the Flip transition.

How can I make dismissViewControllerAnimated use the same transition type also after restoration?


Solution

  • Set the modalTransitionStyle to UIModalTransitionStyleFlipHorizontal after the restoration is complete.