iPhone 4.0模拟器:didFinishPickingMediaWithInfo是否丢失UIImagePickerControllerOriginalImage?

时间:2021-10-25 15:01:33

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

我有一个简单的UIImagePickerController它试图抓取原始的选定图像:

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:

我现在用4.0作为基本SDK,目标是3.1.3。运行4.0模拟器,信息集合只包含:

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

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

在设备上,或者在iPad 3.2模拟器中运行,我得到:

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.

我遗漏了什么东西?在我更新到SDK 4.0之前,它运行得很好。我没有任何警告。

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.

显然,如果没有模拟器中的原始图像,我就不能对所选的图像进行显示或操作,因为我不知道它是什么。

2 个解决方案

#1


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

我运行的设备运行4.0 (3GS)和getitng相同的问题。它以前也运行得很好。所以这不是一个模拟器错误。然而,对我来说,这只是在用户创建相册时才会发生。如果从相机卷中选择或与相机一起拍摄,效果很好:/。

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.

更新:这似乎是苹果的一个bug,因为我们都说过,返回的info字典只包含媒体类型的键-值对,即使这个值是“public”。image"它不返回UIImagePickerControllerOriginalImage键中的图像。我已经提交了错误报告ID# 8176175。

#2


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;

self.imagePicker。allowsEditing =是的;

#1


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

我运行的设备运行4.0 (3GS)和getitng相同的问题。它以前也运行得很好。所以这不是一个模拟器错误。然而,对我来说,这只是在用户创建相册时才会发生。如果从相机卷中选择或与相机一起拍摄,效果很好:/。

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.

更新:这似乎是苹果的一个bug,因为我们都说过,返回的info字典只包含媒体类型的键-值对,即使这个值是“public”。image"它不返回UIImagePickerControllerOriginalImage键中的图像。我已经提交了错误报告ID# 8176175。

#2


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;

self.imagePicker。allowsEditing =是的;