[FIX] Video orientation
This commit is contained in:
parent
764aedd6ff
commit
6ea6bdb13b
|
@ -1,12 +1,13 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'QRCodeReader.swift'
|
||||
s.version = '3.1.3'
|
||||
s.version = '3.1.4'
|
||||
s.license = 'MIT'
|
||||
s.summary = 'Simple QRCode and 1D bar code reader in Swift'
|
||||
s.homepage = 'https://github.com/yannickl/QRCodeReader.swift.git'
|
||||
s.social_media_url = 'https://twitter.com/yannickloriot'
|
||||
s.authors = { 'Yannick Loriot' => 'contact@yannickloriot.com' }
|
||||
s.source = { :git => 'https://github.com/yannickl/QRCodeReader.swift.git', :tag => s.version }
|
||||
s.screenshot = 'http://yannickloriot.com/resources/qrcodereader.swift-screenshot.jpg'
|
||||
|
||||
s.ios.deployment_target = '8.0'
|
||||
|
||||
|
|
|
@ -128,13 +128,13 @@ public final class QRCodeReader: NSObject, AVCaptureMetadataOutputObjectsDelegat
|
|||
|
||||
// MARK: - Managing the Orientation
|
||||
|
||||
/// Returns the video orientation correspongind to the given device orientation.
|
||||
public class func videoOrientationFromDeviceOrientation(deviceOrientation: UIDeviceOrientation) -> AVCaptureVideoOrientation {
|
||||
switch (deviceOrientation) {
|
||||
/// Returns the video orientation correspongind to the given interface orientation.
|
||||
public class func videoOrientationFromInterfaceOrientation(orientation: UIInterfaceOrientation) -> AVCaptureVideoOrientation {
|
||||
switch (orientation) {
|
||||
case .LandscapeLeft:
|
||||
return .LandscapeRight
|
||||
case .LandscapeRight:
|
||||
return .LandscapeLeft
|
||||
case .LandscapeRight:
|
||||
return .LandscapeRight
|
||||
case .Portrait:
|
||||
return .Portrait
|
||||
default:
|
||||
|
|
|
@ -119,9 +119,9 @@ public final class QRCodeReaderViewController: UIViewController {
|
|||
cameraView.setNeedsDisplay()
|
||||
|
||||
if codeReader?.previewLayer.connection != nil {
|
||||
let currentDevice = UIDevice.currentDevice()
|
||||
let orientation = UIApplication.sharedApplication().statusBarOrientation
|
||||
|
||||
codeReader?.previewLayer.connection.videoOrientation = QRCodeReader.videoOrientationFromDeviceOrientation(currentDevice.orientation)
|
||||
codeReader?.previewLayer.connection.videoOrientation = QRCodeReader.videoOrientationFromInterfaceOrientation(orientation)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,9 +136,9 @@ public final class QRCodeReaderViewController: UIViewController {
|
|||
_codeReader.previewLayer.frame = CGRectMake(0, 0, view.frame.size.width, view.frame.size.height)
|
||||
|
||||
if _codeReader.previewLayer.connection.supportsVideoOrientation {
|
||||
let currentDevice = UIDevice.currentDevice()
|
||||
let orientation = UIApplication.sharedApplication().statusBarOrientation
|
||||
|
||||
_codeReader.previewLayer.connection.videoOrientation = QRCodeReader.videoOrientationFromDeviceOrientation(currentDevice.orientation)
|
||||
_codeReader.previewLayer.connection.videoOrientation = QRCodeReader.videoOrientationFromInterfaceOrientation(orientation)
|
||||
}
|
||||
|
||||
if _codeReader.hasFrontDevice() {
|
||||
|
|
Loading…
Reference in New Issue