diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2019-05-07 09:19:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-07 09:19:52 -0400 |
commit | fb4937d50aaa285fd928f1506ea00047a1ce07d2 (patch) | |
tree | 92ed08aa16767706a59b3645e18ecce0c21228ea | |
parent | 7c28d635fb99594ba401e32a28e6c067513098b3 (diff) | |
parent | 00419ab6f4df546670c4bad3f83caa2b83fda538 (diff) | |
download | sdl_ios-fb4937d50aaa285fd928f1506ea00047a1ce07d2.tar.gz |
Merge pull request #1252 from smartdevicelink/bugfix/issue_1250_lockscreen_rotation
Fix Lockscreen Window's Existence Messing with App Autorotation
-rwxr-xr-x | SmartDeviceLink/SDLScreenshotViewController.m | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/SmartDeviceLink/SDLScreenshotViewController.m b/SmartDeviceLink/SDLScreenshotViewController.m index 2d9e73666..e0e965f7a 100755 --- a/SmartDeviceLink/SDLScreenshotViewController.m +++ b/SmartDeviceLink/SDLScreenshotViewController.m @@ -30,6 +30,38 @@ return self; } +// HAX: https://github.com/smartdevicelink/sdl_ios/issues/1250 +- (UIInterfaceOrientationMask)supportedInterfaceOrientations { + UIViewController *viewController = [self sdl_topMostControllerForWindow:[UIApplication sharedApplication].windows[0]]; + + if (viewController != nil) { + return viewController.supportedInterfaceOrientations; + } + + return super.supportedInterfaceOrientations; +} + +// HAX: https://github.com/smartdevicelink/sdl_ios/issues/1250 +- (BOOL)shouldAutorotate { + UIViewController *viewController = [self sdl_topMostControllerForWindow:[UIApplication sharedApplication].windows[0]]; + + if (viewController != nil) { + return viewController.shouldAutorotate; + } + + return super.shouldAutorotate; +} + +- (UIViewController *)sdl_topMostControllerForWindow:(UIWindow *)window { + UIViewController *topController = window.rootViewController; + + while (topController.presentedViewController) { + topController = topController.presentedViewController; + } + + return topController; +} + - (void)layoutSubviews { self.imageView.frame = self.view.bounds; } |