Adding a second UIWindow with constrained orientation in its root view controller breaks the orientation logic

Originator:vladimir
Number:rdar://18406156 Date Originated:21/09/2014
Status:Open Resolved:No
Product:iOS Product Version:iOS 8.0 [12A365]
Classification:UI/Usability Reproducible:Always
 
Summary:
In an app that supports all orientations (as set in info.plist), we add a second UIWindow programmatically. This second UIWindow has a root view controller that only supports landscape orientation. If this window should be added while the device is in portrait orientation, there are two options (both bad):

1. If we create the second window with a [UIScreen mainScreen].bounds frame, the second window assumes portrait frame, cutting its root view controller's view.
2. If we create the second window with a "rotated" screen bounds, the second window looks fine, but after rotating the device a few times, the *original* window's frame is broken.

So, no matter what frame the second window is created with, something goes bad.

A sample project is attached.

Steps to Reproduce:
1. Create a new project in Xcode 6 - use a "single view" template.
2. In the project's deployment info, set the supported device orientations to all orientations (portrait and landscape).
3. Add a button to the automatically created view controller, and hook it up to a buttonPressed: IBAction.
4. Create a second view controller - call it MyViewController.
5. In MyViewController, have the shouldAutorotate method return true and the supportedInterfaceOrientations method return UIInterfaceOrientationMaskLandscape.
6. In the buttonPressed: IBAction (From step #3), create a new UIWindow (with [UIScreen mainScreen].bounds as the frame), set its root view controller to a new instance of MyViewController, set the root view controller's background colour to something clearly visible (e.g., green colour), and call the new window's makeKeyAndVisible method.
7. Run the app under iOS 8.
8. Orient the simulator or device to portrait - the app should orient itself to portrait as well.
9. Press the button.

Expected Results:
The new window should be correctly sized to the entire screen, as should be its root view controller. The background colour from step #6 should fill the entire screen.

Actual Results:
It appears as if the window was forced into portrait mode, though the status bar orientation changed to landscape.

Version:
iOS 8.0 [12A365]

Notes:


Configuration:
All iOS 8 devices and simulators

Attachments:
'LandscapeWindowTest.zip' was successfully uploaded. Public URL: https://www.sendspace.com/file/yian5m

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!