Commit 60626aba by Daniel Dahan

updated CaptureView to not call flashButton handle

parent 30b1d92e
...@@ -96,17 +96,22 @@ class ViewController: UIViewController, CaptureSessionDelegate { ...@@ -96,17 +96,22 @@ class ViewController: UIViewController, CaptureSessionDelegate {
internal func handleFlash(sender: AnyObject) { internal func handleFlash(sender: AnyObject) {
var img: UIImage? var img: UIImage?
switch captureView.previewView.captureSession.flashMode {
switch captureView.captureSession.flashMode {
case .Off: case .Off:
img = UIImage(named: "ic_flash_on_white") img = UIImage(named: "ic_flash_on_white")
print("Flash On") captureView.captureSession.flashMode = .On
print("On")
case .On: case .On:
img = UIImage(named: "ic_flash_auto_white") img = UIImage(named: "ic_flash_auto_white")
print("Flash Auto") captureView.captureSession.flashMode = .Off
print("Auto")
case .Auto: case .Auto:
img = UIImage(named: "ic_flash_off_white") img = UIImage(named: "ic_flash_off_white")
print("Flash Off") captureView.captureSession.flashMode = .On
print("Off")
} }
captureView.flashButton?.setImage(img, forState: .Normal) captureView.flashButton?.setImage(img, forState: .Normal)
captureView.flashButton?.setImage(img, forState: .Highlighted) captureView.flashButton?.setImage(img, forState: .Highlighted)
} }
......
...@@ -42,24 +42,6 @@ public class CaptureView : MaterialView, CaptureSessionDelegate, CapturePreviewV ...@@ -42,24 +42,6 @@ public class CaptureView : MaterialView, CaptureSessionDelegate, CapturePreviewV
if let v: UIButton = captureButton { if let v: UIButton = captureButton {
v.removeTarget(self, action: "handleCaptureButton:", forControlEvents: .TouchUpInside) v.removeTarget(self, action: "handleCaptureButton:", forControlEvents: .TouchUpInside)
v.addTarget(self, action: "handleCaptureButton:", forControlEvents: .TouchUpInside) v.addTarget(self, action: "handleCaptureButton:", forControlEvents: .TouchUpInside)
} else {
captureButton?.removeFromSuperview()
captureButton = nil
}
}
}
/**
:name: flashButton
*/
public var flashButton: UIButton? {
didSet {
if let v: UIButton = flashButton {
v.removeTarget(self, action: "handleFlashButton:", forControlEvents: .TouchUpInside)
v.addTarget(self, action: "handleFlashButton:", forControlEvents: .TouchUpInside)
} else {
flashButton?.removeFromSuperview()
flashButton = nil
} }
} }
} }
...@@ -72,14 +54,16 @@ public class CaptureView : MaterialView, CaptureSessionDelegate, CapturePreviewV ...@@ -72,14 +54,16 @@ public class CaptureView : MaterialView, CaptureSessionDelegate, CapturePreviewV
if let v: UIButton = switchCamerasButton { if let v: UIButton = switchCamerasButton {
v.removeTarget(self, action: "handleSwitchCameraButton:", forControlEvents: .TouchUpInside) v.removeTarget(self, action: "handleSwitchCameraButton:", forControlEvents: .TouchUpInside)
v.addTarget(self, action: "handleSwitchCameraButton:", forControlEvents: .TouchUpInside) v.addTarget(self, action: "handleSwitchCameraButton:", forControlEvents: .TouchUpInside)
} else {
switchCamerasButton?.removeFromSuperview()
switchCamerasButton = nil
} }
} }
} }
/** /**
:name: flashButton
*/
public var flashButton: UIButton?
/**
:name: captureSession :name: captureSession
*/ */
public var captureSession: CaptureSession { public var captureSession: CaptureSession {
...@@ -182,25 +166,6 @@ public class CaptureView : MaterialView, CaptureSessionDelegate, CapturePreviewV ...@@ -182,25 +166,6 @@ public class CaptureView : MaterialView, CaptureSessionDelegate, CapturePreviewV
} }
/** /**
:name: handleFlashButton
*/
internal func handleFlashButton(button: UIButton) {
print(captureSession.flashMode == .Off)
switch captureSession.flashMode {
case .Off:
captureSession.flashMode = .On
print("On")
case .On:
captureSession.flashMode = .Off
print("Auto")
case .Auto:
print("Off")
captureSession.flashMode = .On
}
}
/**
:name: preparePreviewView :name: preparePreviewView
*/ */
private func preparePreviewView() { private func preparePreviewView() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment