@@ -74,6 +74,7 @@ - (void)setupWithQuality:(NSString *)quality
7474 _fixOrientationAfterCapture = NO ;
7575 _tapToFocus = YES ;
7676 _useDeviceOrientation = NO ;
77+ _useDeviceOrientationOnCapture = YES ;
7778 _flash = LLCameraFlashOff;
7879 _mirror = LLCameraMirrorAuto;
7980 _videoEnabled = videoEnabled;
@@ -250,7 +251,7 @@ - (void)initialize
250251
251252 if ([self .session canAddInput: _videoDeviceInput]) {
252253 [self .session addInput: _videoDeviceInput];
253- self.captureVideoPreviewLayer .connection .videoOrientation = [self orientationForConnection ];
254+ self.captureVideoPreviewLayer .connection .videoOrientation = [self orientationForConnection: false ];
254255 }
255256
256257 // add audio if video is enabled
@@ -313,7 +314,7 @@ -(void)capture:(void (^)(LLSimpleCamera *camera, UIImage *image, NSDictionary *m
313314
314315 // get connection and set orientation
315316 AVCaptureConnection *videoConnection = [self captureConnection ];
316- videoConnection.videoOrientation = [self orientationForConnection ];
317+ videoConnection.videoOrientation = [self orientationForConnection: true ];
317318
318319 // freeze the screen
319320 [self .captureVideoPreviewLayer.connection setEnabled: NO ];
@@ -382,7 +383,7 @@ - (void)startRecordingWithOutputUrl:(NSURL *)url
382383 // get only the video media types
383384 if ([[port mediaType ] isEqual: AVMediaTypeVideo]) {
384385 if ([connection isVideoOrientationSupported ]) {
385- [connection setVideoOrientation: [self orientationForConnection ]];
386+ [connection setVideoOrientation: [self orientationForConnection: false ]];
386387 }
387388 }
388389 }
@@ -846,14 +847,14 @@ - (void)viewWillLayoutSubviews
846847 self.captureVideoPreviewLayer .bounds = bounds;
847848 self.captureVideoPreviewLayer .position = CGPointMake (CGRectGetMidX (bounds), CGRectGetMidY (bounds));
848849
849- self.captureVideoPreviewLayer .connection .videoOrientation = [self orientationForConnection ];
850+ self.captureVideoPreviewLayer .connection .videoOrientation = [self orientationForConnection: false ];
850851}
851852
852- - (AVCaptureVideoOrientation)orientationForConnection
853+ - (AVCaptureVideoOrientation)orientationForConnection : ( BOOL ) capture
853854{
854855 AVCaptureVideoOrientation videoOrientation = AVCaptureVideoOrientationPortrait;
855856
856- if (self.useDeviceOrientation ) {
857+ if (self.useDeviceOrientation || (self. useDeviceOrientationOnCapture && capture) ) {
857858 switch ([UIDevice currentDevice ].orientation ) {
858859 case UIDeviceOrientationLandscapeLeft:
859860 // yes we to the right, this is not bug!
0 commit comments