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> #import <Cordova/CDVViewController.h>
@interface CDVOrientation : CDVPlugin @interface CDVOrientation : CDVPlugin
{} {
@protected
UIInterfaceOrientation _lastOrientation;
}
- (void)screenOrientation:(CDVInvokedUrlCommand *)command; - (void)screenOrientation:(CDVInvokedUrlCommand *)command;

View File

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