-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
SDLLockScreenPresenter overrides native app's supportedInterfaceOrientations and shouldAutorotate properties #1250
Comments
In order to make sure the - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
UIViewController *viewController = [UIApplication sharedApplication].windows[0].rootViewController;
if (viewController) {
return viewController.supportedInterfaceOrientations;
}
return super.supportedInterfaceOrientations;
}
- (BOOL)shouldAutorotate {
UIViewController *viewController = [UIApplication sharedApplication].windows[0].rootViewController;
if (viewController) {
return viewController.shouldAutorotate;
}
return super.shouldAutorotate;
} |
Also, an interesting note in th Apple docs regarding
|
I don't think the code you gave will work in all cases. For example, if the root view controller is a |
@SatbirTanda please check my PR #1252. Thank you for the detailed issue, reproduction steps, example projects, etc. It made fixing this bug much easier and faster! |
Attached is an example project showing the fix including a fix for presented view controllers, which I did confirm was not fixed by the code given above. We have to traverse the root view controller to check for modally presented views and use their autorotation preferences if they exist. Note that we do not need to check the navigation controller or tab bar controller because the autorotation preferences don't cascade that way. If they want to offer different autorotation preferences per tab bar tab or navigation controller child controller, they must do something to return the child controller's rotation preferences within the container controller. As such, we don't traverse those containers for their children. |
Bug Report
If a developer wants to create an app that supports both portrait and landscape orientation for some (not all) of their view controllers (with SDL integrated), then they should expect their portrait only view controllers to stay the same even if the device is rotated. When
SDLLockScreenPresenter
is initialized, it creates a newUIWindow
object that, for some reason, alters the properties of view controllers in otherUIWindow
objects in the app to match that of it'srootViewController
- including those view controllers that are in the native app'sUIWindow
object. This results in the status bar auto-rotating to conform toSDLScreenshotViewController
'ssupportedInterfaceOrientations
andshouldAutorotate
properties.Reproduction Steps
SDLManager
object and call itsstart
method (in AppDelegate).Expected Behavior
View controllers that only support the portrait orientation should not see the status bar rotate when the device rotates
Observed Behavior
View controllers that only support the portrait orientation do see the status bar rotate when the device rotates
OS & Version Information
Test Case, Sample Code, and / or Example App
I've attached two example apps that display the bug, one that initializes its AppDelegate's window property in code, and the other that initializes via Storyboards.
StatusBarBug-Nibs.zip
StatusBarBug-StoryBoard.zip
The text was updated successfully, but these errors were encountered: