- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
在我的应用程序中,我使用 card.io 扫描信用卡。它在 iOS 9 中运行良好。在 iOS 10 中,应用程序崩溃了,我在 xcode 8 beta 2 控制台中找不到崩溃日志,因为它会抛出大量垃圾消息。
然后我检查了隐私-> 设置以查看我的应用程序是否禁用了相机,但我的应用程序未在该部分中列出。似乎 iOS 10 没有授予我的应用程序使用相机的权限。
我使用以下代码请求权限:
-(BOOL)checkCameraPermissions{
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if(authStatus == AVAuthorizationStatusAuthorized)
{
// start card-io
return YES;
}
else if(authStatus == AVAuthorizationStatusNotDetermined)
{
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)
{
if(granted)
{
//Start card-io
[self testIsNewCard];
}
}];
}
else if (authStatus == AVAuthorizationStatusRestricted)
{
//Alert
// Alert camera denied
UIAlertController *aCon=[UIAlertController alertControllerWithTitle:@"Camera denied" message:@"Camera cannot be used" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok =[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[aCon dismissViewControllerAnimated:YES completion:nil];
}];
[aCon addAction:ok];
[self presentViewController:aCon animated:YES completion:nil];
return NO;
}
return NO;
}
当我运行这段代码时,authStatus 返回为 AVAuthorizationStatusNotDetermined
应用程序在进入 block requestAccessForMediaType:AVMediaTypeVideo
后立即崩溃
控制台中显示了太多垃圾日志,我不知道如何找到崩溃消息。
编辑: 我找到了一个选项来禁用 xcode 8 中所有不必要的日志。答案已发布 here.但即使在禁用回溯调试后,xcode 仍然没有显示任何崩溃日志。
我的 xcode8 刚刚显示这条消息,应用程序刚刚退出:
App[1124:226447] [access] <private>
我也尝试重置位置和隐私,但在尝试请求媒体访问时应用程序仍然崩溃。
知道为什么会这样吗?
最佳答案
我将“Privacy - Camera Usage Description”
key 添加到我的 info.plist 文件中,现在可以使用了。
关于objective-c - requestAccessForMediaType 在 iOS 10 中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38267608/
我注意到我的应用未请求使用相机的权限。经过一些实验后,我发现用于检查权限的代码需要很长时间才能完成。所以我想到让我的 viewdidload 的那部分在串行队列(同步)上运行。强制其余部分在开始下一行
macOS 10.14 NSMicrophoneUsageDescription Record audio! 这适用于一个快速的项目: AVCaptureDevice.requestAcces
我在使用 iOS 10 的设备上遇到问题,在首次启动应用程序时,当我尝试使用相机时,会出现弹出窗口,说明应用程序需要使用相机的原因,用户要么接受要么拒绝它,应用程序将崩溃。之后,应用程序在启动画面上崩
我正在检查某个应用是否有权使用相机: let authStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo
我在询问用户有关相机的权限时遇到了一些问题。 authorizationStatus 始终为 NotDetermined。当我尝试向用户请求许可时,AVCaptureDevice.requestAcc
在我的应用程序中,我使用 card.io 扫描信用卡。它在 iOS 9 中运行良好。在 iOS 10 中,应用程序崩溃了,我在 xcode 8 beta 2 控制台中找不到崩溃日志,因为它会抛出大量垃
我是一名优秀的程序员,十分优秀!