From 5865a1affcc5aee86a4c8cc0b860689f7220ebbc Mon Sep 17 00:00:00 2001 From: Kyle Corbitt Date: Fri, 5 Feb 2016 12:02:45 +0000 Subject: [PATCH] orientation in landscape initializes properly --- ios/RCTCameraManager.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ios/RCTCameraManager.m b/ios/RCTCameraManager.m index e375329..82d064b 100644 --- a/ios/RCTCameraManager.m +++ b/ios/RCTCameraManager.m @@ -213,7 +213,16 @@ RCT_EXPORT_METHOD(changeFlashMode:(NSInteger)flashMode) { } RCT_EXPORT_METHOD(changeOrientation:(NSInteger)orientation) { - self.previewLayer.connection.videoOrientation = orientation; + if (self.previewLayer.connection.isVideoOrientationSupported) { + self.previewLayer.connection.videoOrientation = orientation; + } + else { + // Setting videoOrientation isn't yet supported, so we have to wait until + // startSession has finished to set it. Put this in the queue behind. + dispatch_async(self.sessionQueue, ^{ + self.previewLayer.connection.videoOrientation = orientation; + }); + } } RCT_EXPORT_METHOD(changeTorchMode:(NSInteger)torchMode) {