3

I've got a simple UIImagePickerController which tries to grab the original selected image:

if ([UIImagePickerController isSourceTypeAvailable:
     UIImagePickerControllerSourceTypePhotoLibrary]) {

    if(defaultpicker == nil){
        defaultpicker = [[UIImagePickerController alloc] init];
    }

    defaultpicker.delegate = self;
    defaultpicker.allowsEditing = NO;
    defaultpicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    [self presentModalViewController:defaultpicker animated:YES];
}

Upon selecting:

- (void)imagePickerController:(UIImagePickerController *)imagepicker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    [imagepicker dismissModalViewControllerAnimated:YES];

    NSString* key = nil;

    for(key in info){
        NSLog(@"Info: %@", key);
    }

    UIImage *theImage = (UIImage *)[info objectForKey: UIImagePickerControllerOriginalImage];

I'm using 4.0 as the base SDK, and targeting 3.1.3 at the moment. Running the 4.0 simulator, the info collection only contains:

2010-07-07 16:19:33.414 ******[516:307] Info: UIImagePickerControllerMediaType

On the device, or running in the iPad 3.2 simulator I get:

2010-07-07 16:19:33.405 ****[516:307] Info: UIImagePickerControllerOriginalImage

2010-07-07 16:19:33.414 ****[516:307] Info: UIImagePickerControllerMediaType

Am I missing something? This was working fine before I updated to SDK 4.0. I have no warning etc.

Obviously, without the original image in the simulator, I can't show or do anything with the selected image as I have no idea what it is.

Pang
  • 9,564
  • 146
  • 81
  • 122
nullabletype
  • 290
  • 3
  • 13
  • 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: http://stackoverflow.com/questions/3088874/didfinishpickingmediawithinfo-return-nil-photo/4192109 – Matthew Frederick Nov 16 '10 at 07:59

2 Answers2

3

Im running on a device running 4.0 (a 3GS) and getitng the same problem. It worked fine before as well. So it is not a simulator error. However for me this only seems to be happening if it is a user created photo album. if selected from the camera roll or taken with the camera it works fine :/.

If i find a solution (working on it now) will post.

Update: It appears to be a bug with apple, since as we both stated, the info dictionary that is returned only contains the key-value pair of the media type even though this value is "public.image" it does not return that image in the UIImagePickerControllerOriginalImage key as it should. I have submitted a bug report Bug ID# 8176175.

Jesse Naugher
  • 9,780
  • 1
  • 41
  • 56
  • 2
    update: Apple responded to the bug support. This is a follow up to Bug ID# 8176175. After further investigation it has been determined that this is a known issue, which is currently being investigated by engineering. This issue has been filed in our bug database under the original Bug ID# 8113630. The original bug number being used to track this duplicate issue can be found in the State column, in this format: Duplicate/OrigBug#. Thank you for submitting this bug report. We truly appreciate your assistance in helping us discover and isolate bugs. – Jesse Naugher Jul 13 '10 at 17:46
0

I was getting this as well, but if you choose this you will get them both(for now it looks a like a workaround):

self.imagePicker.allowsEditing = YES;

James
  • 1,553
  • 2
  • 11
  • 13
  • I just debugged directly on the iPhone itself, which is rather slow and painful but at least I know it behaves correctly on the device! – nullabletype Jul 30 '10 at 13:53