willRotateToInterfaceOrientation:duration: not called for iOS5 after dismissing from modal

Posted by Jean-Denis Muys on Stack Overflow See other posts from Stack Overflow or by Jean-Denis Muys
Published on 2011-11-28T09:47:14Z Indexed on 2011/11/28 9:50 UTC
Read the original article Hit count: 618

Filed under:
|
|

My main UIViewController overrides willRotateToInterfaceOrientation:duration: to adapt the background view for the correct orientation. This works fine when staying within the view.

But in my app, the result of some user actions can lead to presenting another "daughter" UIViewController. When the user is done with that daughter UIViewController, she normally returns to the main view controller. My code calls dismissModalViewControllerAnimated: to do so.

The issue occurs when the user changes the iPad orientation while the daughter UIViewController is on screen. Then, the main UIViewController will never see any call to willRotateToInterfaceOrientation:duration: and its background view will be incorrect.

This setup works fine in iOS 4: the iOS 4 implementation of dismissModalViewControllerAnimated: calls UIWindow's _setRotatableClient:toOrientation:updateStatusBar:duration:force: which calls willRotateToInterfaceOrientation:duration: for the switched in UIViewController.

Apparently , this behavior changed for iOS 5.

How am I expected to implemented orientation changes while my view is off screen under iOS5? Am I supposed to query the current orientation in viewWillAppear: for example?

© Stack Overflow or respective owner

Related posts about cocoa-touch

Related posts about ios5