Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPad UIImagePicker in UIPopoverController selecting only Saved images (not from Album)?

In my iPad application, I'm letting the user select an image using the following code:

UIImagePickerController* picker = [[UIImagePickerController alloc] init]; 
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
picker.delegate = self; 

UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
self.popoverController = popover;          
popoverController.delegate = self;
[popoverController presentPopoverFromRect:self.view.frame
                                   inView:self.view
                 permittedArrowDirections:UIPopoverArrowDirectionAny
                                 animated:YES];
[picker release];

(I've set up the class to be both a UIPopoverControllerDelegate and a UIImagePickerControllerDelegate, and I've setup the callbacks for both delegates.)

Now, the weird thing is that if I select an image from the "Saved Photos" photo album, my "imagePickerController: didFinishPickingImage" callback method gets called, and I get an image, and all is well.

But, if I select an image from any of the other albums, my "imagePickerControllerDidCancel" callback gets called - and I don't get back an image.

Any idea? I've searched the web high-and-low...

Thanks, Reuven


The plot thickens...

When adding:
allowsEditing = YES;

I can still select (and crop/scale) images from the Saved Photos album - but when trying to Use images from other albums, the iPad crashes with the debugger showing:

2010-06-03 08:16:06.759 uPrintMobile[98412:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: UIImagePickerControllerOriginalImage)'

Still no clue...

like image 373
Reuven Avatar asked Nov 05 '22 12:11

Reuven


1 Answers

I know this is many months later, but I struggled with the same problem and found that though it was asked here many times, it was never answered. Well, I'm happy to say that I figured it out and so am posting it on a few of the nearly-identical questions that come up first on a search.

I posted the full answer here:
didFinishPickingMediaWithInfo return nil photo

like image 129
Matthew Frederick Avatar answered Nov 15 '22 12:11

Matthew Frederick