iPhone 4.0 Simulator: didFinishPickingMediaWithInfo is missing UIImagePickerControllerOriginalImage?
I've got a simple UIImagePickerController
which tries to grab the original selected image:
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypePhotoLibrary]) {
if(defaultpicker == nil){
defaultpicker = [[UIImagePickerController alloc] 开发者_Go百科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.
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.
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;
精彩评论