twostraws / CodeScanner

A SwiftUI view that is able to scan barcodes, QR codes, and more, and send back what was found.
MIT License
1.01k stars 286 forks source link

Landscape mode shows wrong orientation for a split second in .sheet() #92

Open sdavidliu opened 1 year ago

sdavidliu commented 1 year ago

I'm adding CodeScanner into a .sheet() for my iPad app that is primarily in landscape mode. When the sheet appears, the camera is briefly shown rotated 90 degrees, and then it fixes itself within a second. Was wondering if there's a simple fix for this.

Here is my setup:

VStack {
    Button(action: { showModal.toggle() }, label: { Text("Button") })
}
.sheet(isPresented: $showModal, content: {
    VStack {
        CodeScannerView(codeTypes: [.qr], videoCaptureDevice: AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .front)) { response in
            print(response)
        }
    }
})