我看了很多关于这个问题,只有增加的代码行上的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()
}
})
其他地方函数'startScanning'被调用吗? –
ya函数在pod文件中被调用。 –
该调用不在'requestCameraPermission'块中吗? –