【发布时间】:2016-03-19 13:45:10
【问题描述】:
我想在我的应用中访问相机。我正在尝试以下代码。
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
if(isIOS8SystemVersion)
{
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self presentViewController:picker animated:YES completion:NULL];
}];
}
else
{
[self presentViewController:picker animated:YES completion:NULL];
}
}
此代码在我的其他应用程序上完美运行。但在此应用程序中,它不会询问相机权限或在设置->隐私->相机中显示它。
应用提示使用该位置。但没有显示任何相机或照片。
没有条件检查直接使用相机代码出现黑屏无法拍照。
【问题讨论】:
-
查看此链接以获取您的解决方案:stackoverflow.com/a/16756715/3378413
-
不行。我试过了。
-
你用的是哪个ios版本?
-
转到设置并向下滚动并点击您的应用。并验证是否显示了摄像头?
-
不显示。我已在此处添加图像。它仅显示位置访问。查看图像。它来自我的 iPad。
标签: ios objective-c ipad camera ios9.1