3

I got this error in using iPad. But iPhone is worked. Please share the solution. My code is given below.

-(void)pickImageFromLibrary
{

    UIImagePickerController *picker10 = [[UIImagePickerController alloc] init];
    picker10.delegate = self;
    picker10.allowsEditing = YES;
    picker10.view.tag=100;


        picker10.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

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


}
Juan Catalan
  • 2,299
  • 1
  • 17
  • 23
Barani E
  • 49
  • 1
  • 3
  • May be this will help you http://stackoverflow.com/questions/24942282/uiimagepickercontroller-not-presenting-in-ios-8 – Aznix Nov 18 '15 at 05:55

2 Answers2

2

you should try this code!

[self.presentedViewController dismissViewControllerAnimated:NO completion:nil];
Rajesh Gupta
  • 127
  • 1
  • 5
  • 3
    Please [edit] with more information. Code-only and "try this" answers are [discouraged](http://meta.stackexchange.com/questions/196187), because they contain no searchable content, and don't explain why someone should "try this". We make an effort here to be a resource for knowledge. – Mogsdad Aug 26 '15 at 14:33
0

UIImagePickerCopntroller must be presented in popover in iPad. take a look at the following code for iPad:

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
    UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
    [popover presentPopoverFromRect:self.selectedImageView.bounds inView:self.selectedImageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    self.popOver = popover;
} else {
    [self presentModalViewController:picker animated:YES];
}

don't forget to add a strong property for the popover:

@property (nonatomic, strong) UIPopoverController *popOver;

here are the delegate methods for dismissing it:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker

here is the link to the class reference for more info: Class Refference

Adrian P
  • 6,479
  • 4
  • 38
  • 55