views:

120

answers:

2

Holy Crap! Really... I'm frustrated with this problem that get me stuck with my apps for a week now.

Here is the code

- (IBAction)loadTheImage {


 UIImagePickerController * picker = [[UIImagePickerController alloc] init];

 picker.delegate = self;

 picker.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;

 // picker.sourceType =  UIImagePickerControllerSourceTypeSavedPhotosAlbum;

 [self presentModalViewController:picker animated:YES];
}

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

 [picker dismissModalViewControllerAnimated:YES];

 imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
}

If I set the source as SavedPhotosAlbum (Camera Roll), then it works OK. But when I set it to PhotoLibrary, it just returns nil. And this just happens in OS3.1.2. In OS4 it works OK (ie returns the original image just fine).

Anybody?

A: 

A given source may not always be available on every device. This could be because the source is not physically present or because it cannot currently be accessed.

Before attempting to use an UIImagePickerController object to pick an image, you must call [UIImagePickerController isSourceTypeAvailable:] method to ensure that the desired source type is available.

jamapag
A: 

Sorry I don't know how to reply to answer... so Im gonna post here.

@TechZen, nil is the value for original image only. I can access info dictionary's edited image fine. But just the original image is nil, hence not returning any image.

@jamapag, I am testing this in a simulator (though it is same result in device). I have put the checking for sourcetype as you suggested, but the original image is still returning nil. The edited image is returned fine by the way (if I set allowsEditing=YES).

Anyone else can help, pls do. I don't know how else I could solve this problem...

Rocotilos