[FIX] Video orientation

This commit is contained in:
Yannick Loriot 2015-03-07 12:47:08 +01:00
parent 764aedd6ff
commit 6ea6bdb13b
4 changed files with 12 additions and 11 deletions

View File

@ -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'

View File

@ -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:

View File

@ -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() {

View File

@ -26,7 +26,7 @@ $ touch Podfile
$ edit Podfile
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
pod 'QRCodeReader.swift', '~> 3.1.3'
pod 'QRCodeReader.swift', '~> 3.1.4'
```
Install into your project: