diff --git a/camera.xcodeproj/project.pbxproj b/camera.xcodeproj/project.pbxproj index 40eaa43..a47d310 100644 --- a/camera.xcodeproj/project.pbxproj +++ b/camera.xcodeproj/project.pbxproj @@ -208,7 +208,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; PROVISIONING_PROFILE = "4d0a483e-6fa4-454e-a019-6ce6d8c6f307"; @@ -246,7 +246,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; MTL_ENABLE_DEBUG_INFO = NO; PROVISIONING_PROFILE = "4d0a483e-6fa4-454e-a019-6ce6d8c6f307"; SDKROOT = iphoneos; @@ -260,6 +260,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = camera/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; }; @@ -270,6 +271,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = camera/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; }; diff --git a/camera.xcodeproj/project.xcworkspace/xcuserdata/nataliaterlecka.xcuserdatad/UserInterfaceState.xcuserstate b/camera.xcodeproj/project.xcworkspace/xcuserdata/nataliaterlecka.xcuserdatad/UserInterfaceState.xcuserstate index 8390cdb..a4fcc5e 100644 Binary files a/camera.xcodeproj/project.xcworkspace/xcuserdata/nataliaterlecka.xcuserdatad/UserInterfaceState.xcuserstate and b/camera.xcodeproj/project.xcworkspace/xcuserdata/nataliaterlecka.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/camera/CameraManager.swift b/camera/CameraManager.swift index a03d115..2c5e9eb 100644 --- a/camera/CameraManager.swift +++ b/camera/CameraManager.swift @@ -204,7 +204,8 @@ class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate { } } self.captureSession?.commitConfiguration() - + self._orientationChanged() + self.currentCameraOutputMode = newCameraOutputMode } } @@ -440,22 +441,42 @@ class CameraManager: NSObject, AVCaptureFileOutputRecordingDelegate { @objc private func _orientationChanged() { + var currentConnection: AVCaptureConnection?; + switch self.cameraOutputMode { + case .StillImage: + currentConnection = self.stillImageOutput?.connectionWithMediaType(AVMediaTypeVideo) + case .VideoOnly, .VideoWithMic: + currentConnection = self.movieOutput?.connectionWithMediaType(AVMediaTypeVideo) + } + if let validPreviewLayer = self.previewLayer? { if let validPreviewLayerConnection = validPreviewLayer.connection? { - switch UIDevice.currentDevice().orientation { - case .LandscapeLeft: - validPreviewLayerConnection.videoOrientation = .LandscapeRight - case .LandscapeRight: - validPreviewLayerConnection.videoOrientation = .LandscapeLeft - default: - validPreviewLayerConnection.videoOrientation = .Portrait + if validPreviewLayerConnection.supportsVideoOrientation { + validPreviewLayerConnection.videoOrientation = self._currentVideoOrientation() } - dispatch_async(dispatch_get_main_queue(), { () -> Void in - if let validEmbedingView = self.embedingView? { - validPreviewLayer.frame = validEmbedingView.bounds - } - }) } + if let validOutputLayerConnection = currentConnection? { + if validOutputLayerConnection.supportsVideoOrientation { + validOutputLayerConnection.videoOrientation = self._currentVideoOrientation() + } + } + dispatch_async(dispatch_get_main_queue(), { () -> Void in + if let validEmbedingView = self.embedingView? { + validPreviewLayer.frame = validEmbedingView.bounds + } + }) + } + } + + private func _currentVideoOrientation() -> AVCaptureVideoOrientation + { + switch UIDevice.currentDevice().orientation { + case .LandscapeLeft: + return .LandscapeRight + case .LandscapeRight: + return .LandscapeLeft + default: + return .Portrait } } diff --git a/camera/ViewController.swift b/camera/ViewController.swift index 9ddce08..d1905d8 100644 --- a/camera/ViewController.swift +++ b/camera/ViewController.swift @@ -46,7 +46,6 @@ class ViewController: UIViewController { self.cameraManager.stopCaptureSession() } - // MARK: - @IBActions @IBAction func changeFlashMode(sender: UIButton)