5

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...

Tim Post
  • 33,371
  • 15
  • 110
  • 174
Reuven
  • 2,142
  • 3
  • 18
  • 30
  • HAVE U GOT ANY SOLUTION FOR THIS PART.I also got struck here .please help if you got the solution – Vipin Apr 28 '11 at 13:28
  • Christina, what version of xcode/ios are you using? – Reuven May 02 '11 at 08:45
  • Hi this is the same case for me as well. Tested with iPad SIMULATOR 5.0,5.1,6.0 all gave OrigninalImage and/or EditedImage as nil.Only iPad SIM 4.3 works ok. On device, my iPad is running 5.1.1 and it WORKS. So I'm guessing a bug in the iPad sim and ignoring it. – GeneCode Sep 15 '12 at 10:00

2 Answers2

2

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

Community
  • 1
  • 1
Matthew Frederick
  • 22,245
  • 10
  • 71
  • 97
0

Try playing around the other options of UIImagePickerControllerSourceTypePhotoLibrary in your delegate method, check the condition like

`if( image is from photo library ) {
   // do something
} else if ( image from saved albums ) {
   // do something
}`
Nikesh K
  • 621
  • 6
  • 10