Skip to content

Commit a89e94c

Browse files
Landscape Issue Fix and prevent orientation change when already in orientation
1 parent c5802c5 commit a89e94c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/ios/CDVOrientation.m

+7-6
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ -(void)screenOrientation:(CDVInvokedUrlCommand *)command
4242
[result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown]];
4343
}
4444
if(orientationMask & 4) {
45-
[result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]];
45+
[result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]];
4646
}
4747
if(orientationMask & 8) {
48-
[result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]];
48+
[result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]];
4949
}
5050

5151
SEL selector = NSSelectorFromString(@"setSupportedOrientations:");
@@ -61,11 +61,12 @@ -(void)screenOrientation:(CDVInvokedUrlCommand *)command
6161
if (!_isLocked) {
6262
_lastOrientation = [UIApplication sharedApplication].statusBarOrientation;
6363
}
64-
if(orientationMask == 8 || orientationMask == 12) {
65-
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
66-
} else if (orientationMask == 4){
64+
UIInterfaceOrientation deviceOrientation = [UIApplication sharedApplication].statusBarOrientation;
65+
if(orientationMask == 8 || (orientationMask == 12 && !UIInterfaceOrientationIsLandscape(deviceOrientation))) {
6766
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
68-
} else if (orientationMask == 1 || orientationMask == 3) {
67+
} else if (orientationMask == 4){
68+
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
69+
} else if (orientationMask == 1 || (orientationMask == 3 && !UIInterfaceOrientationIsPortrait(deviceOrientation))) {
6970
value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
7071
} else if (orientationMask == 2) {
7172
value = [NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown];

0 commit comments

Comments
 (0)