Skip to content

Commit bc1b7c2

Browse files
committed
Allows all orientations for the camera
1 parent a588747 commit bc1b7c2

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

Sources/BarcodeScannerController.swift

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,14 @@ open class BarcodeScannerController: UIViewController {
311311

312312
if let videoPreviewLayer = videoPreviewLayer {
313313
videoPreviewLayer.frame = view.layer.bounds
314-
315-
if videoPreviewLayer.connection != nil {
316-
videoPreviewLayer.connection.videoOrientation = .portrait
314+
if let connection = videoPreviewLayer.connection, connection.isVideoOrientationSupported {
315+
switch (UIApplication.shared.statusBarOrientation) {
316+
case .portrait: connection.videoOrientation = .portrait
317+
case .landscapeRight: connection.videoOrientation = .landscapeRight
318+
case .landscapeLeft: connection.videoOrientation = .landscapeLeft
319+
case .portraitUpsideDown: connection.videoOrientation = .portraitUpsideDown
320+
default: connection.videoOrientation = .portrait
321+
}
317322
}
318323
}
319324

@@ -337,12 +342,6 @@ open class BarcodeScannerController: UIViewController {
337342
height: size.height)
338343
}
339344

340-
// MARK: - Orientation
341-
342-
open override var supportedInterfaceOrientations : UIInterfaceOrientationMask {
343-
return .portrait
344-
}
345-
346345
// MARK: - Animations
347346

348347
/**

0 commit comments

Comments
 (0)