You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/07/01 12:38:50 UTC

[GitHub] jcesarmobile closed pull request #20: Rotate device only if needed

jcesarmobile closed pull request #20: Rotate device only if needed
URL: https://github.com/apache/cordova-plugin-screen-orientation/pull/20
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/ios/CDVOrientation.m b/src/ios/CDVOrientation.m
index c7704e4..f23911a 100644
--- a/src/ios/CDVOrientation.m
+++ b/src/ios/CDVOrientation.m
@@ -53,13 +53,18 @@ -(void)screenOrientation:(CDVInvokedUrlCommand *)command
     if([vc respondsToSelector:selector]) {
         ((void (*)(CDVViewController*, SEL, NSMutableArray*))objc_msgSend)(vc,selector,result);
         
+        UIInterfaceOrientation deviceOrientation = [UIApplication sharedApplication].statusBarOrientation;
+        
+        // Update orientation only if needed.
+        // Prevent switch from UIInterfaceOrientationLandscapeLeft to UIInterfaceOrientationLandscapeRight and
+        // from UIInterfaceOrientationPortraitUpsideDown to UIInterfaceOrientationPortrait
         if ([UIDevice currentDevice] != nil){
             NSNumber *value = nil;
-            if(orientationMask == 8 || orientationMask == 12) {
+            if(orientationMask == 8 || (orientationMask == 12 && !UIInterfaceOrientationIsLandscape(deviceOrientation))) {
                 value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
             } else if (orientationMask == 4){
                 value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
-            } else if (orientationMask == 1 || orientationMask == 3) {
+            } else if (orientationMask == 1 || (orientationMask == 3 && !UIInterfaceOrientationIsPortrait(deviceOrientation))) {
                 value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
             } else if (orientationMask == 2) {
                 value = [NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown];


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org