From d94441f334e2f04eb818618ecfd3bf8f8b5a9790 Mon Sep 17 00:00:00 2001 From: Venkatesh Kommineni Date: Mon, 4 Apr 2016 11:14:13 +0100 Subject: [PATCH] Updating to use Interface Orientation instead of Device Orientation --- RCTOrientation/Orientation.m | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/RCTOrientation/Orientation.m b/RCTOrientation/Orientation.m index fce0ebee..c01ebd46 100644 --- a/RCTOrientation/Orientation.m +++ b/RCTOrientation/Orientation.m @@ -43,7 +43,7 @@ - (void)dealloc - (void)deviceOrientationDidChange:(NSNotification *)notification { - UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; + UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; [_bridge.eventDispatcher sendDeviceEventWithName:@"specificOrientationDidChange" body:@{@"specificOrientation": [self getSpecificOrientationStr:orientation]}]; @@ -52,19 +52,19 @@ - (void)deviceOrientationDidChange:(NSNotification *)notification } -- (NSString *)getOrientationStr: (UIDeviceOrientation)orientation { +- (NSString *)getOrientationStr: (UIInterfaceOrientation)orientation { NSString *orientationStr; switch (orientation) { - case UIDeviceOrientationPortrait: + case UIInterfaceOrientationPortrait: orientationStr = @"PORTRAIT"; break; - case UIDeviceOrientationLandscapeLeft: - case UIDeviceOrientationLandscapeRight: + case UIInterfaceOrientationLandscapeLeft: + case UIInterfaceOrientationLandscapeRight: orientationStr = @"LANDSCAPE"; break; - case UIDeviceOrientationPortraitUpsideDown: + case UIInterfaceOrientationPortraitUpsideDown: orientationStr = @"PORTRAITUPSIDEDOWN"; break; @@ -75,22 +75,22 @@ - (NSString *)getOrientationStr: (UIDeviceOrientation)orientation { return orientationStr; } -- (NSString *)getSpecificOrientationStr: (UIDeviceOrientation)orientation { +- (NSString *)getSpecificOrientationStr: (UIInterfaceOrientation)orientation { NSString *orientationStr; switch (orientation) { - case UIDeviceOrientationPortrait: + case UIInterfaceOrientationPortrait: orientationStr = @"PORTRAIT"; break; - case UIDeviceOrientationLandscapeLeft: + case UIInterfaceOrientationLandscapeLeft: orientationStr = @"LANDSCAPE-LEFT"; break; - case UIDeviceOrientationLandscapeRight: + case UIInterfaceOrientationLandscapeRight: orientationStr = @"LANDSCAPE-RIGHT"; break; - case UIDeviceOrientationPortraitUpsideDown: + case UIInterfaceOrientationPortraitUpsideDown: orientationStr = @"PORTRAITUPSIDEDOWN"; break; @@ -105,14 +105,14 @@ - (NSString *)getSpecificOrientationStr: (UIDeviceOrientation)orientation { RCT_EXPORT_METHOD(getOrientation:(RCTResponseSenderBlock)callback) { - UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; + UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; NSString *orientationStr = [self getOrientationStr:orientation]; callback(@[[NSNull null], orientationStr]); } RCT_EXPORT_METHOD(getSpecificOrientation:(RCTResponseSenderBlock)callback) { - UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; + UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; NSString *orientationStr = [self getSpecificOrientationStr:orientation]; callback(@[[NSNull null], orientationStr]); } @@ -179,7 +179,7 @@ - (NSString *)getSpecificOrientationStr: (UIDeviceOrientation)orientation { - (NSDictionary *)constantsToExport { - UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; + UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; NSString *orientationStr = [self getOrientationStr:orientation]; return @{