IsOrientationSupported deprecated in iOS

I am getting this error and I have no idea how to fix it.

WARNING: -[<AVCaptureVideoPreviewLayer: 0xad482c0> isOrientationSupported] is deprecated. Please use AVCaptureConnection -isVideoOrientationSupported 

however, when I look at the documentation apples, it says that it is a Mac OS function .. not iOS ... so I'm a bit confused ... I look forward to hearing. Thanks..

+8
ios objective-c iphone
source share
3 answers

AVCaptureConnection is also available for iOS here . You probably specified the wrong documentation.

+3
source share

Example code for an example that works with pre-6.0:

 if ([captureVideoPreviewLayer respondsToSelector:@selector(connection)]) { if ([captureVideoPreviewLayer.connection isVideoOrientationSupported]) { [captureVideoPreviewLayer.connection setVideoOrientation:self.interfaceOrientation]; } } else { // Deprecated in 6.0; here for backward compatibility if ([captureVideoPreviewLayer isOrientationSupported]) { [captureVideoPreviewLayer setOrientation:self.interfaceOrientation]; } } 
+26
source share

The above sample code example works fine. But you need to replace yourself. interfaceOrientation with AVCaptureVideoOrientation.

The edited code is as follows.

 if ([captureVideoPreviewLayer.connection isVideoOrientationSupported]) { [captureVideoPreviewLayer.connection setVideoOrientation:AVCaptureVideoOrientationPortrait]; } 

Depending on the requirement, the orientation will look like portrait or landscape.

Updates and suggestions are welcome.

+1
source share

All Articles