在我的项目中,我尝试添加两件事:一个人的化身的相机来源。在info.plist文件中添加摄像头和照片库访问权限。但当我试图在…中测试我的应用程序时…
在你的 addNewPerson() 在显示警报之前,您应检查用户是否已授予对其摄像头的访问权限,您可以通过以下方式执行此操作:
addNewPerson()
if AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo) == AVAuthorizationStatus.Authorized { // Already Authorized } else { AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo, completionHandler: { (granted: Bool) -> Void in if granted == true { // User granted } else { // User rejected } }) }
在此之前确保你添加