[英]Swift, has got me on this one: interfaceOrientation was deprecated in iOS 8.0
It's not a do or die, but have not had any luck with hacking this. 这不是一成不变的事情,但是对于黑客入侵并没有任何运气。 Thanks.
谢谢。
if session.canAddInput(videoDeviceInput){
session.addInput(videoDeviceInput)
self.videoDeviceInput = videoDeviceInput
dispatch_async(dispatch_get_main_queue(), {
// ERROR HERE
let orientation: AVCaptureVideoOrientation = AVCaptureVideoOrientation(rawValue: self.interfaceOrientation.rawValue)!
(self.previewView.layer as! AVCaptureVideoPreviewLayer).connection.videoOrientation = orientation
})
}
Yeah, it was depecrated. 是的,它已经废止了。 You can use
UIApplication.sharedApplication().statusBarOrientation
instead. 您可以改用
UIApplication.sharedApplication().statusBarOrientation
。
let orientation: AVCaptureVideoOrientation?
switch UIApplication.sharedApplication().statusBarOrientation{
case .LandscapeLeft:
orientation = .LandscapeLeft
case .LandscapeRight:
orientation = .LandscapeRight
case .Portrait:
orientation = .Portrait
case .PortraitUpsideDown:
orientation = .PortraitUpsideDown
case .Unknown:
orientation = nil
}
if let orientation = orientation{
(self.previewView.layer as! AVCaptureVideoPreviewLayer).connection.videoOrientation = orientation
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.