Reputation: 49
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];
}
Upvotes: 3
Views: 4450
Reputation: 127
you should try this code!
[self.presentedViewController dismissViewControllerAnimated:NO completion:nil];
Upvotes: 2
Reputation: 6529
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
Upvotes: 0