From a89e94c2b8bdefecca5583b795fac779b3a0c341 Mon Sep 17 00:00:00 2001 From: Fortunes Technology Date: Mon, 12 Feb 2018 10:06:54 +0800 Subject: [PATCH] Landscape Issue Fix and prevent orientation change when already in orientation --- src/ios/CDVOrientation.m | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ios/CDVOrientation.m b/src/ios/CDVOrientation.m index 0152680..ff718f8 100644 --- a/src/ios/CDVOrientation.m +++ b/src/ios/CDVOrientation.m @@ -42,10 +42,10 @@ [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown]]; } if(orientationMask & 4) { - [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]]; + [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]]; } if(orientationMask & 8) { - [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]]; + [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]]; } SEL selector = NSSelectorFromString(@"setSupportedOrientations:"); @@ -61,11 +61,12 @@ if (!_isLocked) { _lastOrientation = [UIApplication sharedApplication].statusBarOrientation; } - if(orientationMask == 8 || orientationMask == 12) { - value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]; - } else if (orientationMask == 4){ + UIInterfaceOrientation deviceOrientation = [UIApplication sharedApplication].statusBarOrientation; + if(orientationMask == 8 || (orientationMask == 12 && !UIInterfaceOrientationIsLandscape(deviceOrientation))) { value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]; - } else if (orientationMask == 1 || orientationMask == 3) { + } else if (orientationMask == 4){ + value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]; + } else if (orientationMask == 1 || (orientationMask == 3 && !UIInterfaceOrientationIsPortrait(deviceOrientation))) { value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait]; } else if (orientationMask == 2) { value = [NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown];