gpt4 book ai didi

swift - AVCaptureDevice.requestAccessForMediaType 从不弹出窗口,始终返回 false

转载 作者:搜寻专家 更新时间:2023-10-31 08:20:42 24 4
gpt4 key购买 nike

我在询问用户有关相机的权限时遇到了一些问题。 authorizationStatus 始终为 NotDetermined。当我尝试向用户请求许可时,AVCaptureDevice.requestAccessForMediaType 永远不会弹出对话框,并且 granted 总是返回 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
}

最佳答案

问题解决了。似乎当我们从 iOS 8 升级到 iOS 9 时,它在 info.plist 中有一个新属性,即 Bundle Display Name。 name 为 null 则设置为你的产品名称,否则系统将永远不知道哪个应用程序正在请求权限

关于swift - AVCaptureDevice.requestAccessForMediaType 从不弹出窗口,始终返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34696761/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com