"interfaceOrientation" is deprecated in iOS 8, How to change this method Objective C

cocoa-touch, ios, objective-c

Solution

Getting the device orientation is not correct. For instance, the device might be in landscape mode, but a view controller that only supports portrait will remain in portrait.

Instead, use this:

[[UIApplication sharedApplication] statusBarOrientation]

Another bonus is that it still uses the UIInterfaceOrientation enum, so very little of your code needs to change.

Problem

I have downloaded a simpleCamera view from Cocoa Controls which use this method ``` - (AVCaptureVideoOrientation)orientationForConnection { AVCaptureVideoOrientation videoOrientation = AVCaptureVideoOrientationPortrait; switch (self.interfaceOrientation) { case UIInterfaceOrientationLandscapeLeft: videoOrientation = AVCaptureVideoOrientationLandscapeLeft; break; case UIInterfaceOrientationLandscapeRight: videoOrientation = AVCaptureVideoOrientationLandscapeRight; break; case UIInterfaceOrientationPortraitUpsideDown: videoOrientation = AVCaptureVideoOrientationPortraitUpsideDown; break; default: videoOrientation = AVCaptureVideoOrientationPortrait; break; } return videoOrientation; } ``` the problem is "interfaceOrientation" deprecated in iOS 8 but i dont know what and how to replace this in Switch condition.

Original source

Related problems