Skip to content

Commit

Permalink
use status bar orientation info when the device orientation returns U…
Browse files Browse the repository at this point in the history
…nknown (#104)
  • Loading branch information
ldom authored and stoneman1 committed Sep 10, 2017
1 parent 3c7f330 commit 5aace9e
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions iOS/RCTOrientation/Orientation.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,25 @@ - (NSString *)getOrientationStr: (UIDeviceOrientation)orientation {
break;

default:
orientationStr = @"UNKNOWN";
// orientation is unknown, we try to get the status bar orientation
switch ([[UIApplication sharedApplication] statusBarOrientation]) {
case UIInterfaceOrientationPortrait:
orientationStr = @"PORTRAIT";
break;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:

orientationStr = @"LANDSCAPE";
break;

case UIInterfaceOrientationPortraitUpsideDown:
orientationStr = @"PORTRAITUPSIDEDOWN";
break;

default:
orientationStr = @"UNKNOWN";
break;
}
break;
}
return orientationStr;
Expand All @@ -88,7 +106,25 @@ - (NSString *)getSpecificOrientationStr: (UIDeviceOrientation)orientation {
break;

default:
orientationStr = @"UNKNOWN";
// orientation is unknown, we try to get the status bar orientation
switch ([[UIApplication sharedApplication] statusBarOrientation]) {
case UIInterfaceOrientationPortrait:
orientationStr = @"PORTRAIT";
break;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:

orientationStr = @"LANDSCAPE";
break;

case UIInterfaceOrientationPortraitUpsideDown:
orientationStr = @"PORTRAITUPSIDEDOWN";
break;

default:
orientationStr = @"UNKNOWN";
break;
}
break;
}
return orientationStr;
Expand Down

0 comments on commit 5aace9e

Please sign in to comment.