Creating a new UIWindow breaks orientation changes in certain cases

Originator:joel
Number:rdar://50405134 Date Originated:05/02/2019
Status:OPEN Resolved:
Product:UIKit Product Version:12.2
Classification: Reproducible:Always
 
This bug was reported against our framework (https://github.com/smartdevicelink/sdl_ios/issues/1250). Basically, it appears that merely initializing a new UIWindow, even if it's not on screen, causes status bar orientation changes even when the view controller in the visible window declares that it does not change orientation.

The issue linked above describes the issue in detail.

Steps to Reproduce:
1. Set the UIViewControllerBasedStatusBarAppearance property to YES in Info.plist of the app
```xml	
        <key>UIViewControllerBasedStatusBarAppearance</key>
	<true/>
```
2. Make sure your app supports Landscape left, landscape right, portrait (can be done in Target or Info.plist)
3. Now, you should be able to choose (through your code) which view controllers will support which orientations.
4.  Thus if one view controller only wanted to support portrait, then override supportedInterfaceOrientations to return .portrait 
5.  Create a new window object with a root view controller that supports all interface orientations that the app supports.
6.  Use app and rotate the device to landscape - you will see the status bar rotate even though the view controller supports portrait only

Expected Results:
View controllers that only support the portrait orientation should not see the status bar rotate when the device rotates

Actual Results:
View controllers that only support the portrait orientation do see the status bar rotate when the device rotates

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!