The camera shows a black screen in ios 8

This code is to capture the image one by one from the camera, but after taking one shot, the next time the camera will open, but with a black screen (for example, with the shutter closed). All other versions of ios work but not work 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];
   }

 }

      

+3


source to share


3 answers


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

In your code, use this to check for camera access.



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

      

+2


source


this code doesn't 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];

      

+1


source


Implementation This method

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

      

0


source







All Articles