Fix Autorotate and demo project

This commit is contained in:
Andrew Walz 2017-01-02 19:35:11 -07:00
parent 2f3f719ebd
commit b85adadc29
4 changed files with 24 additions and 15 deletions

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16C48b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D17a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -35,16 +35,27 @@
<action selector="cameraSwitchAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="a9E-90-SZM"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oLI-bi-joD" customClass="SwiftyCamButton" customModule="DemoSwiftyCam" customModuleProvider="target">
<rect key="frame" x="152" y="577" width="70" height="70"/>
<constraints>
<constraint firstAttribute="height" constant="70" id="lUb-f5-HQX"/>
<constraint firstAttribute="width" constant="70" id="zFC-Ge-J3i"/>
</constraints>
<state key="normal" image="Camera"/>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Bb3-ix-Jd1" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="8" symbolic="YES" id="2Fx-Ut-jDO"/>
<constraint firstAttribute="bottom" secondItem="oLI-bi-joD" secondAttribute="bottom" constant="20" symbolic="YES" id="4S8-Ik-CMc"/>
<constraint firstItem="oLI-bi-joD" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="7MO-81-gs9"/>
<constraint firstAttribute="trailingMargin" secondItem="SH4-0K-8ra" secondAttribute="trailing" constant="4" id="AiE-Y6-Sxj"/>
<constraint firstItem="Bb3-ix-Jd1" firstAttribute="centerY" secondItem="SH4-0K-8ra" secondAttribute="centerY" id="Cnv-VO-rR3"/>
<constraint firstItem="Bb3-ix-Jd1" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" constant="4" id="yuS-xl-hcP"/>
</constraints>
</view>
<connections>
<outlet property="captureButton" destination="oLI-bi-joD" id="yVB-gR-PEV"/>
<outlet property="flipCameraButton" destination="Bb3-ix-Jd1" id="Q9m-ib-9iQ"/>
<outlet property="toggleFlashButton" destination="SH4-0K-8ra" id="BSt-X8-4Do"/>
</connections>
@ -54,6 +65,7 @@
</scene>
</scenes>
<resources>
<image name="Camera" width="70" height="70"/>
<image name="Flash" width="30" height="19"/>
<image name="flipCamera" width="30" height="26"/>
</resources>

View file

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

View file

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

View file

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