Only change the UI orientation if it's actually necessary for the mode.
authorSam Lantinga <slouken@libsdl.org>
Sat, 29 Sep 2012 16:41:32 -0700
changeset 6516 044ce237801a
parent 6515 f750d9ecae1e
child 6517 4a4031308518
Only change the UI orientation if it's actually necessary for the mode.
src/video/uikit/SDL_uikitvideo.m
--- a/src/video/uikit/SDL_uikitvideo.m	Sat Sep 29 03:42:40 2012 -0700
+++ b/src/video/uikit/SDL_uikitvideo.m	Sat Sep 29 16:41:32 2012 -0700
@@ -357,11 +357,12 @@
         SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)mode->driverdata;
         [data->uiscreen setCurrentMode:modedata->uiscreenmode];
 
-        CGSize size = [modedata->uiscreenmode size];
-        if (size.width >= size.height) {
-            [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
-        } else {
-            [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
+        if (mode->w > mode->h) {
+            if (!UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
+                [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
+        } else if (mode->w < mode->h) {
+            if (!UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]))
+                [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
         }
     }