mirror of
https://github.com/passepartoutvpn/wireguard-apple.git
synced 2025-02-12 10:52:03 +00:00
Support some form of rotation.
This commit is contained in:
parent
f51bef7673
commit
2e2ffe8634
@ -67,6 +67,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) {
|
func scanDidComplete(withCode code: String) {
|
||||||
do {
|
do {
|
||||||
let tunnel = try Tunnel.fromConfig(code, context: viewContext)
|
let tunnel = try Tunnel.fromConfig(code, context: viewContext)
|
||||||
|
Loading…
Reference in New Issue
Block a user