Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera not focusing #113

Closed
A-Fairooz opened this issue Aug 3, 2023 · 0 comments · Fixed by #127
Closed

Camera not focusing #113

A-Fairooz opened this issue Aug 3, 2023 · 0 comments · Fixed by #127

Comments

@A-Fairooz
Copy link

I ran into the issue where my camera wouldn't refocus, I narrowed down the cause to the initialization of the CodeScannerView

 public init(
        codeTypes: [AVMetadataObject.ObjectType],
        scanMode: ScanMode = .once,
        manualSelect: Bool = false,
        scanInterval: Double = 2.0,
        showViewfinder: Bool = false,
        simulatedData: String = "",
        shouldVibrateOnSuccess: Bool = true,
        isTorchOn: Bool = false,
        isGalleryPresented: Binding<Bool> = .constant(false),
        videoCaptureDevice: AVCaptureDevice? = AVCaptureDevice.bestForVideo, // <---- THIS
        completion: @escaping (Result<ScanResult, ScanError>) -> Void
    )

When setting the videoCaptureDevice, having it set to bestForVideo on later iPhones sets it to the wide-angle lens and stops you from manually being able to focus, my current fix was replacing it with this:

videoCaptureDevice: AVCaptureDevice? = AVCaptureDevice.default(for: .video)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant