react-native-camera-kit
react-native-camera-kit copied to clipboard
When device is not in Portrait, preview of the camera is wrongly oriented
Issue Description
When device is not in Portrait, preview of the camera is wrongly oriented
Steps to Reproduce / Code Snippets / Screenshots
I include it like this
<Camera
ref={camera}
cameraType={CameraType.Back}
saveToCameraRoll={false}
/>
I managed to overcome the issue by changing the code in CKCamera.m
- (void) adjustOrientation:(AVCaptureConnection *)connection
{
switch([UIDevice currentDevice].orientation) {
default:
case UIDeviceOrientationPortrait:
connection.videoOrientation = AVCaptureVideoOrientationPortrait;
break;
case UIDeviceOrientationPortraitUpsideDown:
connection.videoOrientation = AVCaptureVideoOrientationPortraitUpsideDown;
break;
case UIDeviceOrientationLandscapeLeft:
connection.videoOrientation = AVCaptureVideoOrientationLandscapeRight;
break;
case UIDeviceOrientationLandscapeRight:
connection.videoOrientation = AVCaptureVideoOrientationLandscapeLeft;
break;
}
}
call it in 3 places:
in reactSetFrame, right after the line self.previewLayer.frame = self.bounds,
[self adjustOrientation:self.previewLayer.connection];
in orientationChanged, first line:
[self adjustOrientation:self.previewLayer.connection];
in setupCaptureSession, in the condition if (connection.isVideoOrientationSupported) {, replace its contents with
[self adjustOrientation:connection];
[self adjustOrientation:self.previewLayer.connection];
Environment
- React Native Navigation version: 5.9.4
- React Native version: 0.63.2
- Platform(s) (iOS, Android, or both?): iOS
- Device info (Simulator/Device? OS version? Debug/Release?): Device, iPadOS 14.8