我尝试下面的代码来通过相机捕获图像。此代码在iPhone 6下方的所有设备中都能正常运行 此代码在iPHone6和iPhone6 +中不起作用。它显示黑屏。
enter code here
(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
switch (buttonIndex)
{
case 0: NSLog(@"Photo Butten Clicked");
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[App_Delegate.window.rootViewController presentViewController:picker animated:YES completion:nil];
// [self presentViewController:picker animated:YES completion:NULL];
break;
case 1: NSLog(@"Camera Butten Clicked");
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[App_Delegate.window.rootViewController presentViewController:picker animated:YES completion:nil];
// [self presentViewController:picker animated:YES completion:NULL];
break;
default:
break;
}
}
答案 0 :(得分:2)
2)在设置列表中找到您的应用程序。
3)并为您的应用程序提供相机访问权限(允许"应用程序名称"访问)。
答案 1 :(得分:1)
我得到了解决方案。我只是替换 下面的代码
[App_Delegate.window.rootViewController
presentViewController:picker
animated:YES
completion:nil];
使用此代码
[self presentViewController:picker animated:YES completion:NULL];