Landscape Issue Fix and prevent orientation change when already in orientation

This commit is contained in:
Fortunes Technology 2018-02-12 10:06:54 +08:00
parent c5802c5d6a
commit a89e94c2b8

View File

@ -42,10 +42,10 @@
[result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown]]; [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown]];
} }
if(orientationMask & 4) { if(orientationMask & 4) {
[result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]]; [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]];
} }
if(orientationMask & 8) { if(orientationMask & 8) {
[result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]]; [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]];
} }
SEL selector = NSSelectorFromString(@"setSupportedOrientations:"); SEL selector = NSSelectorFromString(@"setSupportedOrientations:");
@ -61,11 +61,12 @@
if (!_isLocked) { if (!_isLocked) {
_lastOrientation = [UIApplication sharedApplication].statusBarOrientation; _lastOrientation = [UIApplication sharedApplication].statusBarOrientation;
} }
if(orientationMask == 8 || orientationMask == 12) { UIInterfaceOrientation deviceOrientation = [UIApplication sharedApplication].statusBarOrientation;
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]; if(orientationMask == 8 || (orientationMask == 12 && !UIInterfaceOrientationIsLandscape(deviceOrientation))) {
} else if (orientationMask == 4){
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]; 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]; value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
} else if (orientationMask == 2) { } else if (orientationMask == 2) {
value = [NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown]; value = [NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown];