From 9a98cd6e6520d348b0be067360236c50181e9983 Mon Sep 17 00:00:00 2001 From: Marijan Vukcevich Date: Tue, 4 Feb 2014 10:10:50 -0800 Subject: [PATCH] Update cap_ios_abstract_camera.mm AVCaptureVideoPreviewLayer setOrientation is depricated. This fixes the warning and provides backward compatibility. --- modules/highgui/src/cap_ios_abstract_camera.mm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/highgui/src/cap_ios_abstract_camera.mm b/modules/highgui/src/cap_ios_abstract_camera.mm index a77e200a82..6675a9db63 100644 --- a/modules/highgui/src/cap_ios_abstract_camera.mm +++ b/modules/highgui/src/cap_ios_abstract_camera.mm @@ -278,9 +278,21 @@ { self.captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession]; - if ([self.captureVideoPreviewLayer isOrientationSupported]) { - [self.captureVideoPreviewLayer setOrientation:self.defaultAVCaptureVideoOrientation]; - } + if ([self.captureVideoPreviewLayer respondsToSelector:@selector(connection)]) + { + if ([self.captureVideoPreviewLayer.connection isVideoOrientationSupported]) + { + [self.captureVideoPreviewLayer.connection setVideoOrientation:self.defaultAVCaptureVideoOrientation]; + } + } + else + { + // Deprecated in 6.0; here for backward compatibility + if ([self.captureVideoPreviewLayer isOrientationSupported]) + { + [self.captureVideoPreviewLayer setOrientation:self.defaultAVCaptureVideoOrientation]; + } + } if (parentView != nil) { self.captureVideoPreviewLayer.frame = self.parentView.bounds;