Skip to content

Commit

Permalink
Merge pull request #130 from HakFlo/master
Browse files Browse the repository at this point in the history
Add initialCameraPosition feature.
  • Loading branch information
3lvis authored Oct 8, 2020
2 parents 399b2e5 + e8dc0a8 commit a8b0bc2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ let viewController = BarcodeScannerViewController()
viewController.cameraViewController.barCodeFocusViewType = .animated
// Show camera position button
viewController.cameraViewController.showsCameraButton = true
// Set the initial camera position
viewController.cameraViewController.initialCameraPosition = .front // Default is .back
// Set settings button text
let title = NSAttributedString(
string: "Settings",
Expand Down
3 changes: 2 additions & 1 deletion Sources/Controllers/CameraViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public final class CameraViewController: UIViewController {

/// Focus view type.
public var barCodeFocusViewType: FocusViewType = .animated
public var initialCameraPosition: AVCaptureDevice.Position = .back
public var showsCameraButton: Bool = false {
didSet {
cameraButton.isHidden = showsCameraButton
Expand Down Expand Up @@ -213,7 +214,7 @@ public final class CameraViewController: UIViewController {
}

if error == nil {
strongSelf.setupSessionInput(for: .back)
strongSelf.setupSessionInput(for: strongSelf.initialCameraPosition)
strongSelf.setupSessionOutput()
strongSelf.delegate?.cameraViewControllerDidSetupCaptureSession(strongSelf)
} else {
Expand Down

0 comments on commit a8b0bc2

Please sign in to comment.