Skip to content

Commit a8b0bc2

Browse files
authored
Merge pull request #130 from HakFlo/master
Add initialCameraPosition feature.
2 parents 399b2e5 + e8dc0a8 commit a8b0bc2

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ let viewController = BarcodeScannerViewController()
185185
viewController.cameraViewController.barCodeFocusViewType = .animated
186186
// Show camera position button
187187
viewController.cameraViewController.showsCameraButton = true
188+
// Set the initial camera position
189+
viewController.cameraViewController.initialCameraPosition = .front // Default is .back
188190
// Set settings button text
189191
let title = NSAttributedString(
190192
string: "Settings",

Sources/Controllers/CameraViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public final class CameraViewController: UIViewController {
1919

2020
/// Focus view type.
2121
public var barCodeFocusViewType: FocusViewType = .animated
22+
public var initialCameraPosition: AVCaptureDevice.Position = .back
2223
public var showsCameraButton: Bool = false {
2324
didSet {
2425
cameraButton.isHidden = showsCameraButton
@@ -213,7 +214,7 @@ public final class CameraViewController: UIViewController {
213214
}
214215

215216
if error == nil {
216-
strongSelf.setupSessionInput(for: .back)
217+
strongSelf.setupSessionInput(for: strongSelf.initialCameraPosition)
217218
strongSelf.setupSessionOutput()
218219
strongSelf.delegate?.cameraViewControllerDidSetupCaptureSession(strongSelf)
219220
} else {

0 commit comments

Comments
 (0)