CB-13405: (ios) Screen unlock bug fix

This commit is contained in:
Dan Field 2017-10-05 14:13:26 -04:00
parent 63955da87b
commit 114aeef0bb
2 changed files with 20 additions and 9 deletions

View File

@ -24,7 +24,10 @@
#import <Cordova/CDVViewController.h>
@interface CDVOrientation : CDVPlugin
{}
{
@protected
UIInterfaceOrientation _lastOrientation;
}
- (void)screenOrientation:(CDVInvokedUrlCommand *)command;

View File

@ -55,17 +55,25 @@
if ([UIDevice currentDevice] != nil){
NSNumber *value = nil;
if(orientationMask == 8 || orientationMask == 12) {
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
} else if (orientationMask == 4){
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
} else if (orientationMask == 1 || orientationMask == 3) {
value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
} else if (orientationMask == 2) {
value = [NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown];
if (orientationMask != 15) {
_lastOrientation = [UIApplication sharedApplication].statusBarOrientation;
if(orientationMask == 8 || orientationMask == 12) {
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
} else if (orientationMask == 4){
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
} else if (orientationMask == 1 || orientationMask == 3) {
value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
} else if (orientationMask == 2) {
value = [NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown];
}
} else {
if (_lastOrientation != nil) {
value = [NSNumber numberWithInt:_lastOrientation];
}
}
if (value != nil) {
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
[UINavigationController attemptRotationToDeviceOrientation];
}
}