-->

Camera show black screen in ios 8

2019-04-11 08:51发布

问题:

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