我开发iOS应用程序,使用摄像头。AVCaptureDeviceInput用于与相机进行接口交互。 我检查授权状态如下:
- (void)checkDeviceAuthorizationStatus
{
NSString *mediaType = AVMediaTypeVideo;
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
if (granted)
{
//Granted access to mediaType
[self setDeviceAuthorized:YES];
}
else
{
//Not granted access to mediaType
dispatch_async(dispatch_get_main_queue(), ^{
[[[UIAlertView alloc] initWithTitle:@"AVCam!"
message:@"AVCam doesn't have permission to use Camera, please change privacy settings"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil] show];
[self setDeviceAuthorized:NO];
});
}
}];
}
当我启动应用程序时,为什么它不会要求用户授权访问相机?因此,该应用程序不会出现在设置/隐私/相机中,以手动允许访问相机。然后显示此错误消息“AVCam没有权限使用相机,请更改隐私设置”,应用程序无法使用相机。
编辑:这意味着未经用户许可,应用程序不允许访问相机。不仅如此,相册也有相同的问题。
所有这些都是在我重置设置中发生的(设置/重置/重置所有设置)。在那之前,该应用程序运行良好。