camera UIImagePickerController shows black screen in device ios8

懵懂的女人 提交于 2019-12-10 23:38:23

问题


I am try below code to capture Image through camera. This code is working fine in all device below the iPhone 6 This code is not working in iPHone6 and iPhone6+. It show a black screen.

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;
    }
}

回答1:


You just change setting of you device

Follow these steps

1) Go to device settings.

2) Find your application in setting list.

3) And give camera access permission to your application (under allow "app name" to access).




回答2:


I got solution. I just replace below code

[App_Delegate.window.rootViewController 
        presentViewController:picker 
        animated:YES 
        completion:nil];

with this code

[self presentViewController:picker animated:YES completion:NULL];


来源:https://stackoverflow.com/questions/32391026/camera-uiimagepickercontroller-shows-black-screen-in-device-ios8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!