2017-10-09 65 views
0

我看了很多关于这个问题,只有增加的代码行上的plist喜欢的文章:SWIFT 3征求许可而使用相机

Key  : Privacy - Camera Usage Description 
Value : $(PRODUCT_NAME) camera use 

,但我仍然得到了同样的问题,即

ERROR MESSAGE

'试图在没有摄像头的设备上开始扫描。调用 startScanningWithResultBlock之前方法:检查requestCameraPermissionWithSuccess”

现在看来似乎还没有使用相机上的应用

但后来实际上我们如何获得iOS上的摄像头访问权限设备?

,这是我的代码

MTBBarcodeScanner.requestCameraPermission(success: { success in 
     if success { 
      do { 
       try self.scanner?.startScanning(resultBlock: { codes in 
        if let codes = codes { 
         for code in codes { 
          let stringValue = code.stringValue! 
          print("Found code: \(stringValue)") 

          if (stringValue != nil) 
          { ... } 

            }) 
           })) 
           self.present(alert, animated: true, completion: nil) 
          } 
         } 
        } 
       }) 
      } catch { 
       NSLog("Unable to start scanning") 
      } 
     } else { 
      UIAlertView(title: "Scanning Unavailable", message: "This app does not have permission to access the camera", delegate: nil, cancelButtonTitle: nil, otherButtonTitles: "Ok").show() 
     } 
    }) 
+0

其他地方函数'startScanning'被调用吗? –

+0

ya函数在pod文件中被调用。 –

+0

该调用不在'requestCameraPermission'块中吗? –

回答

0

,以获得进入设备的摄像头,你必须提供一个摄像头的使用说明。 您可以在Info.plist文件中执行此操作。

只需单击“信息属性列表”旁边的“+”图标,然后键入Privacy - Camera Usage Description。 然后,作为一个值提供一个简短的使用信息,例如“我们需要访问才能扫描条形码”。

希望这会有所帮助。

+0

雅我试过了,但是当我在iPad上重新安装应用程序时,它会提示我启用相机使用的任何权限消息 –

相关问题