Arti
Arti

Reputation: 7772

Camera orientation is not changed

I tried this code for scanning barcode:

https://www.hackingwithswift.com/example-code/media/how-to-scan-a-barcode

but it have a bug, when i change orientation of device, camera always has a Protrait orientation...

Any ideas how to fix this ?

I tried to change orientations in this method:

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
        return .Portrait
    }

But it not helps.

Upvotes: 0

Views: 158

Answers (1)

John Doe
John Doe

Reputation: 1609

For a camera to change the orientation you don't want to use that function. Do this instead...

previewLayer!.connection?.videoOrientation = AVCaptureVideoOrientation.Portrait

What this does is when the camera layer is created it sets the orientation.

Upvotes: 1

Related Questions