diff options
author | Jeroen Leenarts <jeroen.leenarts@gmail.com> | 2018-09-20 00:28:07 +0200 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-10-28 23:19:52 +0530 |
commit | 1335724c58e1a4c26e671312df75653d66b4b4a0 (patch) | |
tree | 6aa55687ee46d1af282811e8b68c777424abcc43 | |
parent | QR code: Make sure correct layering is used to make sure hint remains visible. (diff) | |
download | wireguard-apple-1335724c58e1a4c26e671312df75653d66b4b4a0.tar.xz wireguard-apple-1335724c58e1a4c26e671312df75653d66b4b4a0.zip |
QR code: Support some form of rotation.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | WireGuard/WireGuard/UI/iOS/QRScanViewController.swift | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift b/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift index 1725174..6018597 100644 --- a/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift @@ -63,6 +63,38 @@ class QRScanViewController: UIViewController { } } + override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + + if let connection = previewLayer.connection { + + let currentDevice: UIDevice = UIDevice.current + + let orientation: UIDeviceOrientation = currentDevice.orientation + + let previewLayerConnection: AVCaptureConnection = connection + + if previewLayerConnection.isVideoOrientationSupported { + + switch orientation { + case .portrait: + previewLayerConnection.videoOrientation = .portrait + case .landscapeRight: + previewLayerConnection.videoOrientation = .landscapeLeft + case .landscapeLeft: + previewLayerConnection.videoOrientation = .landscapeRight + case .portraitUpsideDown: + previewLayerConnection.videoOrientation = .portraitUpsideDown + default: + previewLayerConnection.videoOrientation = .portrait + + } + } + } + + previewLayer.frame = self.view.bounds + } + func scanDidComplete(withCode code: String) { do { let tunnelConfiguration = try WgQuickConfigFileParser.parse(code, name: "Scanned") |