@@ -133,13 +133,18 @@ class QRScanner : CDVPlugin, AVCaptureMetadataOutputObjectsDelegate {
133133            if  ( captureSession? . isRunning !=  true ) { 
134134                cameraView. backgroundColor =  UIColor . clear
135135                self . webView!. superview!. insertSubview ( cameraView,  belowSubview:  self . webView!) 
136-                 let  availableVideoDevices  =   AVCaptureDevice . devices ( for:  AVMediaType . video) 
137-                 for  device  in  availableVideoDevices { 
138-                     if  device. position ==  AVCaptureDevice . Position. back { 
139-                         backCamera =  device
136+                 let  session  =  AVCaptureDevice . DiscoverySession ( deviceTypes:  [ . builtInWideAngleCamera] ,  mediaType:  AVMediaType . video,  position:  . unspecified) 
137+                 let  cameras  =  session. devices. compactMap  {  $0 } 
138+                 for  camera  in  cameras { 
139+                     if  camera. position ==  . front { 
140+                         self . frontCamera =  camera
141+                         
140142                    } 
141-                     else  if  device. position ==  AVCaptureDevice . Position. front { 
142-                         frontCamera =  device
143+                     if  camera. position ==  . back { 
144+                         self . backCamera =  camera
145+                         try . lockForConfiguration ( ) 
146+                         camera. focusMode =  . continuousAutoFocus
147+                         camera. unlockForConfiguration ( ) 
143148                    } 
144149                } 
145150                // older iPods have no back camera
@@ -197,8 +202,9 @@ class QRScanner : CDVPlugin, AVCaptureMetadataOutputObjectsDelegate {
197202    } 
198203
199204    @objc   func  makeOpaque( ) { 
200-         self . webView? . isOpaque =  false 
201-         self . webView? . backgroundColor =  UIColor . clear
205+         self . webView? . isOpaque =  true 
206+         self . webView? . backgroundColor =  UIColor . white
207+         self . webView? . scrollView. backgroundColor =  UIColor . white
202208    } 
203209
204210    @objc   func  boolToNumberString( bool:  Bool )  ->  String { 
@@ -292,6 +298,7 @@ class QRScanner : CDVPlugin, AVCaptureMetadataOutputObjectsDelegate {
292298    @objc   func  show( _ command:  CDVInvokedUrlCommand )  { 
293299        self . webView? . isOpaque =  false 
294300        self . webView? . backgroundColor =  UIColor . clear
301+         self . webView? . scrollView. backgroundColor =  UIColor . clear
295302        self . getStatus ( command) 
296303    } 
297304
0 commit comments