9
votes

I am creating an iPhone App which uses UIImagePickerController for users to select an image from the photo library.

The picker allows me to get the image from the photo library successfully on:

  • iPhone sumulator
  • real iPhone running 5.0.1
  • real iPad running 5.0.1
  • real iPad running 5.1
  • iPad simulator v4.3

But the picker fails to get the image if I test this app on:

  • iPad simulator v5.0
  • iPad simulator v5.1

On these 2 testing environments, the image picker successfully appears. When I tap the image I need, it just doesn't give me anything from "[info objectForKey:UIImagePickerControllerOriginalImage]" via the method "- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info"

The "info" dictionary is just like this:

{
    UIImagePickerControllerMediaType = "public.image";
    UIImagePickerControllerReferenceURL = "assets-library://asset/asset.PNG?id=7632C58F-AF74-4EEB-AF17-891E35949CBA&ext=PNG";
}

Where as "info" is like this on the former 5 testing environments:

{
    UIImagePickerControllerMediaType = "public.image";
    UIImagePickerControllerOriginalImage = "<UIImage: 0x6bb7810>";
    UIImagePickerControllerReferenceURL = "assets-library://asset/asset.PNG?id=7632C58F-AF74-4EEB-AF17-891E35949CBA&ext=PNG";
}

You can see that UIImagePickerControllerOriginalImage is missing. I am not sure if this is just me?

Note: I am using Xcode 4.3.2 with iOS 5 SDK

Note 2: I am not using AssetsLibrary framework to get the image.

Note 3 (added 2/Aug/2012): I have upgraded to Xcode 4.4 with Mountain Lion installed. The same problem still exists. But now a new error message appears if I run it in iPad simulator v5.0 (the error message doesn't appear if I run it on iPad Simulator v5.1). The error message says: Named service 'com.apple.PersistentURLTranslator.Gatekeeper' not found. assetsd is down or misconfigured. Things will not work the way you expect them to.

Note 4 (added 25/Nov/2012): Using Xcode 4.5.2, this problem still exist in iPad simulator 5.0, 5.1, and 6.0

Note 5 (added 6/Mar/2012): Using Xcode 4.6, this problem still exist in iPad simulator all versions.

2
Hi Wayne, I have same problem in my app, if you find any solution then please shareiBhavik
Sorry i-bhavik, no solution yet. (I just added note 5)Wayne Liu
For Temporary solution i gave answer of this.iBhavik
Does this bug appear on actual devices or only the simulators?Noam Solovechick

2 Answers

0
votes

try this in actual device

     - (IBAction)BrowseImage:(id)sender {

  if ([UIImagePickerController isSourceTypeAvailable:
     UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
    UIImagePickerController *imagePicker =
    [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;
    imagePicker.sourceType = 
    UIImagePickerControllerSourceTypePhotoLibrary;
    imagePicker.mediaTypes = [NSArray arrayWithObjects:
                              (NSString *) kUTTypeImage,
                              nil];
    imagePicker.allowsEditing = NO;
    [self presentModalViewController:imagePicker animated:YES];
    //newMedia = NO;
}   


-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
  {

[self dismissModalViewControllerAnimated:YES];


 }
0
votes

I dont know the problem of that but on temporary option,

imagePicker.allowsEditing = YES;

This will give you image for UIImagePickerControllerOriginalImage,

I know its not the way but...