diff --git a/CameraTutorial.xcodeproj/project.pbxproj b/CameraTutorial.xcodeproj/project.pbxproj index 43b16a9..6711837 100644 --- a/CameraTutorial.xcodeproj/project.pbxproj +++ b/CameraTutorial.xcodeproj/project.pbxproj @@ -161,6 +161,7 @@ TargetAttributes = { 02F5BDDF19CE1C4900EDFD47 = { CreatedOnToolsVersion = 6.1; + DevelopmentTeam = J6H4826VVV; }; 02F5BDF419CE1C4900EDFD47 = { CreatedOnToolsVersion = 6.1; @@ -407,6 +408,7 @@ 02F5BE0119CE1C4900EDFD47 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 02F5BE0219CE1C4900EDFD47 /* Build configuration list for PBXNativeTarget "CameraTutorialTests" */ = { isa = XCConfigurationList; @@ -415,6 +417,7 @@ 02F5BE0419CE1C4900EDFD47 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/CameraTutorial.xcodeproj/project.xcworkspace/xcshareddata/CameraTutorial.xccheckout b/CameraTutorial.xcodeproj/project.xcworkspace/xcshareddata/CameraTutorial.xccheckout new file mode 100644 index 0000000..423a484 --- /dev/null +++ b/CameraTutorial.xcodeproj/project.xcworkspace/xcshareddata/CameraTutorial.xccheckout @@ -0,0 +1,41 @@ + + + + + IDESourceControlProjectFavoriteDictionaryKey + + IDESourceControlProjectIdentifier + F44B9D75-2F78-4C98-896B-7ED2C3CDC9DF + IDESourceControlProjectName + CameraTutorial + IDESourceControlProjectOriginsDictionary + + 3929C7655DEFEA93ECF5D8C0DFDF6F01639B9DE7 + https://github.com/jquave/CameraTutorial.git + + IDESourceControlProjectPath + CameraTutorial.xcodeproj + IDESourceControlProjectRelativeInstallPathDictionary + + 3929C7655DEFEA93ECF5D8C0DFDF6F01639B9DE7 + ../.. + + IDESourceControlProjectURL + https://github.com/jquave/CameraTutorial.git + IDESourceControlProjectVersion + 111 + IDESourceControlProjectWCCIdentifier + 3929C7655DEFEA93ECF5D8C0DFDF6F01639B9DE7 + IDESourceControlProjectWCConfigurations + + + IDESourceControlRepositoryExtensionIdentifierKey + public.vcs.git + IDESourceControlWCCIdentifierKey + 3929C7655DEFEA93ECF5D8C0DFDF6F01639B9DE7 + IDESourceControlWCCName + CameraTutorial + + + + diff --git a/CameraTutorial.xcodeproj/project.xcworkspace/xcuserdata/jquave.xcuserdatad/UserInterfaceState.xcuserstate b/CameraTutorial.xcodeproj/project.xcworkspace/xcuserdata/jquave.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..6910bea Binary files /dev/null and b/CameraTutorial.xcodeproj/project.xcworkspace/xcuserdata/jquave.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/CameraTutorial/Base.lproj/Main.storyboard b/CameraTutorial/Base.lproj/Main.storyboard index 52ea29e..05bb916 100644 --- a/CameraTutorial/Base.lproj/Main.storyboard +++ b/CameraTutorial/Base.lproj/Main.storyboard @@ -1,13 +1,13 @@ - + - + - + diff --git a/CameraTutorial/Info.plist b/CameraTutorial/Info.plist index 4f04142..66648f5 100644 --- a/CameraTutorial/Info.plist +++ b/CameraTutorial/Info.plist @@ -33,8 +33,6 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight diff --git a/CameraTutorial/ViewController.swift b/CameraTutorial/ViewController.swift index 43bb908..bdecfae 100644 --- a/CameraTutorial/ViewController.swift +++ b/CameraTutorial/ViewController.swift @@ -42,28 +42,52 @@ class ViewController: UIViewController { } - func focusTo(value : Float) { + func updateDeviceSettings(focusValue : Float, isoValue : Float) { if let device = captureDevice { if(device.lockForConfiguration(nil)) { - device.setFocusModeLockedWithLensPosition(value, completionHandler: { (time) -> Void in + device.setFocusModeLockedWithLensPosition(focusValue, completionHandler: { (time) -> Void in // }) + + // Adjust the iso to clamp between minIso and maxIso based on the active format + let minISO = device.activeFormat.minISO + let maxISO = device.activeFormat.maxISO + let clampedISO = isoValue * (maxISO - minISO) + minISO + + device.setExposureModeCustomWithDuration(AVCaptureExposureDurationCurrent, ISO: clampedISO, completionHandler: { (time) -> Void in + // + }) + device.unlockForConfiguration() } } } - let screenWidth = UIScreen.mainScreen().bounds.size.width - override func touchesBegan(touches: NSSet, withEvent event: UIEvent) { - var anyTouch = touches.anyObject() as UITouch - var touchPercent = anyTouch.locationInView(self.view).x / screenWidth - focusTo(Float(touchPercent)) + func touchPercent(touch : UITouch) -> CGPoint { + // Get the dimensions of the screen in points + let screenSize = UIScreen.mainScreen().bounds.size + + // Create an empty CGPoint object set to 0, 0 + var touchPer = CGPointZero + + // Set the x and y values to be the value of the tapped position, divided by the width/height of the screen + touchPer.x = touch.locationInView(self.view).x / screenSize.width + touchPer.y = touch.locationInView(self.view).y / screenSize.height + + // Return the populated CGPoint + return touchPer + } + + override func touchesBegan(touches: Set, withEvent event: UIEvent) { + let touchPer = touchPercent( touches.first as! UITouch ) + //focusTo(Float(touchPer.x)) + updateDeviceSettings(Float(touchPer.x), isoValue: Float(touchPer.y)) } - override func touchesMoved(touches: NSSet, withEvent event: UIEvent) { - var anyTouch = touches.anyObject() as UITouch - var touchPercent = anyTouch.locationInView(self.view).x / screenWidth - focusTo(Float(touchPercent)) + override func touchesMoved(touches: Set, withEvent event: UIEvent) { + let touchPer = touchPercent( touches.first as! UITouch ) + //focusTo(Float(touchPer.x)) + updateDeviceSettings(Float(touchPer.x), isoValue: Float(touchPer.y)) } func configureDevice() {