我有一些问题询问用户有关相机的许可.在authorizationStatus
始终NotDetermined
.当我尝试向用户请求权限时,AVCaptureDevice.requestAccessForMediaType
永远不会弹出对话框,并且始终返回false
.我也找不到我的应用程序设置 - 隐私 - 相机.
任何人都可以帮助我吗?非常感谢
let availableCameraDevices = AVCaptureDevice.devicesWithMediaType(AVMediaTypeVideo) for device in availableCameraDevices{ if (device.position == .Back){ backCameraDevice = device }else{ if (device.position == .Front){ frontCameraDevice = device } } } let authorizationStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo) switch authorizationStatus { case .NotDetermined: // permission dialog not yet presented, request authorization AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo, completionHandler: { (granted:Bool) -> Void in if (granted == false) { print(granted) } else { print(granted) } }) case .Authorized: break // go ahead case .Denied, .Restricted: break // the user explicitly denied camera usage or is not allowed to access the camera devices }
Jiatan Li.. 7
问题解决了.似乎当我们从iOS 8升级到iOS 9时,它在info.plist中有一个新属性,即Bundle Display Name.如果名称为null,则将名称设置为您的产品名称,否则系统将永远不会知道要求许可的应用程序
问题解决了.似乎当我们从iOS 8升级到iOS 9时,它在info.plist中有一个新属性,即Bundle Display Name.如果名称为null,则将名称设置为您的产品名称,否则系统将永远不会知道要求许可的应用程序