diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index e33be2c51bd..24c80780462 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -206,7 +206,10 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation) degrees = @90; isLandscape = YES; break; - default: + case UIDeviceOrientationFaceDown: + case UIDeviceOrientationFaceUp: + case UIDeviceOrientationUnknown: + // Unsupported return nil; } return @{ @@ -218,11 +221,15 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation) - (void)namedOrientationDidChange { - UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation; + NSDictionary *orientationEvent = deviceOrientationEventBody([UIDevice currentDevice].orientation); + if (!orientationEvent) { + return; + } + #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" [_bridge.eventDispatcher sendDeviceEventWithName:@"namedOrientationDidChange" - body:deviceOrientationEventBody(deviceOrientation)]; + body:orientationEvent]; #pragma clang diagnostic pop } #endif