1

I am taking picture from Camera.They Shown me Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.

-(IBAction)choosePicture:(id)sender
{
    UIImagePickerController *imagePicker=[[UIImagePickerController alloc]init];
    imagePicker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
    imagePicker.delegate=self;
    [self presentViewController:imagePicker animated:YES completion:nil];


}
-(IBAction)takePicture:(id)sender
{
    UIImagePickerController *imagePicker=[[UIImagePickerController alloc]init];
    imagePicker.sourceType=UIImagePickerControllerSourceTypeCamera;
    imagePicker.delegate = self;

    [self presentViewController:imagePicker animated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
  //  UIImage *pickedImage=[info objectForKey:UIImagePickerControllerOriginalImage];

    image.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

    picker.modalPresentationStyle = UIModalPresentationFullScreen;


    [picker dismissViewControllerAnimated:YES completion:nil];

}
varun
  • 317
  • 1
  • 4
  • 18

2 Answers2

1

Tried your code in an empty app, had no messages, everything is fine.

Besides downloaded example from apple https://developer.apple.com/library/ios/samplecode/PhotoPicker/Introduction/Intro.html

It has the same problem, but everything works fine. May be it's just a bug. (If their own code has the same message)

If you have this message and something doesn't work correctly, try similar questions. for example: UIImagePickerController error: Snapshotting a view that has not been rendered results in an empty snapshot in iOS 7

Community
  • 1
  • 1
1

This worked for me:

-(IBAction)takePicture:(id)sender
{
    UIImagePickerController *imagePickController=[[UIImagePickerController alloc]init];
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
       imagePickController.sourceType = UIImagePickerControllerSourceTypeCamera;
    }
    else
    {
       imagePickController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    }
    imagePickController.delegate = self;
    imagePickController.allowsEditing = TRUE;
    [self presentViewController:imagePickController animated:YES completion:nil];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
  [self dismissViewControllerAnimated:YES completion:nil];
  <your image> = [info objectForKey:UIImagePickerControllerEditedImage];
}
Kaey
  • 4,615
  • 1
  • 14
  • 18