Camera show black screen in ios 8

房东的猫 提交于 2019-12-21 20:12:46

问题


This code for capturing image one by one from camera,but after taking one image next time camera will open but with black screen(like it,s shutter close).all other ios version its working,but not working in ios 8.please tell me how can i solve it?

-(void)openCamera
 {
   if(![PickerHandler doesDeviceSupportMediaType:ITEM_TYPE_PHOTO])
   {
    [PickerHandler showNoDeviceSupportWarningForMediaType:ITEM_TYPE_PHOTO withDelegate:self];
   }
   else 
   {
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;

    picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
    [self presentViewController:picker animated:YES completion:nil];
   }

 }

回答1:


Go to Settings > Privacy > Pictures ... and check if your app have permission.

In the code, use this to verify camera access.

- (BOOL)authorizedCameraAccess
{
    AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
    return  (status == AVAuthorizationStatusAuthorized);
}



回答2:


this code is not work in simulator.

UIImagePickerController *videoScreen = [[UIImagePickerController alloc] init];
    videoScreen.sourceType = UIImagePickerControllerSourceTypeCamera;

    videoScreen.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];

    videoScreen.allowsEditing = NO;
    videoScreen.delegate = self;

    [self presentViewController:videoScreen animated: YES completion:NO];



回答3:


Implement This method

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
 [self dismissViewControllerAnimated:NO completion:NO];
}


来源:https://stackoverflow.com/questions/26652338/camera-show-black-screen-in-ios-8

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