From b85adadc297aace28d31975ff0d8dcb54ec64f50 Mon Sep 17 00:00:00 2001 From: Andrew Walz Date: Mon, 2 Jan 2017 19:35:11 -0700 Subject: [PATCH] Fix Autorotate and demo project --- .../DemoSwiftyCam/Base.lproj/Main.storyboard | 16 ++++++++++++++-- DemoSwiftyCam/DemoSwiftyCam/ViewController.swift | 14 ++++---------- README.md | 2 +- Source/SwiftyCamViewController.swift | 7 +++++-- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/DemoSwiftyCam/DemoSwiftyCam/Base.lproj/Main.storyboard b/DemoSwiftyCam/DemoSwiftyCam/Base.lproj/Main.storyboard index 9648719..eb8ac80 100644 --- a/DemoSwiftyCam/DemoSwiftyCam/Base.lproj/Main.storyboard +++ b/DemoSwiftyCam/DemoSwiftyCam/Base.lproj/Main.storyboard @@ -1,10 +1,10 @@ - + - + @@ -35,16 +35,27 @@ + + + + @@ -54,6 +65,7 @@ + diff --git a/DemoSwiftyCam/DemoSwiftyCam/ViewController.swift b/DemoSwiftyCam/DemoSwiftyCam/ViewController.swift index d3f1dc7..1d8500f 100644 --- a/DemoSwiftyCam/DemoSwiftyCam/ViewController.swift +++ b/DemoSwiftyCam/DemoSwiftyCam/ViewController.swift @@ -20,7 +20,8 @@ class ViewController: SwiftyCamViewController, SwiftyCamViewControllerDelegate { @IBOutlet weak var flipCameraButton: UIButton! @IBOutlet weak var toggleFlashButton: UIButton! - + @IBOutlet weak var captureButton: SwiftyCamButton! + override func viewDidLoad() { super.viewDidLoad() cameraDelegate = self @@ -31,18 +32,11 @@ class ViewController: SwiftyCamViewController, SwiftyCamViewControllerDelegate { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - let button : SwiftyCamButton = SwiftyCamButton(frame: CGRect(x: (self.view.frame.width / 2) - 35, y: self.view.frame.height - 85, width: 70, height: 70)) - button.delegate = self - button.setImage(UIImage(named: "Camera"), for: UIControlState()) - self.view.addSubview(button) + captureButton.delegate = self + self.view.bringSubview(toFront: captureButton) self.view.bringSubview(toFront: flipCameraButton) self.view.bringSubview(toFront: toggleFlashButton) } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } func SwiftyCamDidTakePhoto(_ photo: UIImage) { print(photo) diff --git a/README.md b/README.md index 71026b7..43cea24 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ Video quality can be set by the **videoQuality** property of SwiftyCamViewContro * **.iframe960x540** (AVCaptureSessionPresetiFrame960x540) * **.iframe1280x720** (AVCaptureSessionPresetiFrame1280x720) -The default value is **.resolution1920x1080** +The default value is **.high**. For use with the front-facing camera, **.high** will always be used. ### Maximum Video Duration diff --git a/Source/SwiftyCamViewController.swift b/Source/SwiftyCamViewController.swift index 72f8e0a..a5d913c 100644 --- a/Source/SwiftyCamViewController.swift +++ b/Source/SwiftyCamViewController.swift @@ -65,8 +65,10 @@ open class SwiftyCamViewController: UIViewController { fileprivate var photoFileOutput : AVCaptureStillImageOutput? fileprivate var videoDevice : AVCaptureDevice? fileprivate var previewLayer : PreviewView! - - + + open override var shouldAutorotate: Bool { + return false + } override open func viewDidLoad() { super.viewDidLoad() @@ -96,6 +98,7 @@ open class SwiftyCamViewController: UIViewController { override open func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) + sessionQueue.async { switch self.setupResult { case .success: