iPhone 4.0 模拟器:didFinishPickingMediaWithInfo 缺少 UIImagePickerControllerOriginalImage?
我有一个简单的 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];
}
选择后:
- (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];
我使用 4.0 作为基础 SDK,目前的目标是 3.1.3。运行 4.0 模拟器,信息集合仅包含:
2010-07-07 16:19:33.414 ******[516:307] Info: UIImagePickerControllerMediaType
在设备上,或在 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
我错过了什么吗?在我更新到 SDK 4.0 之前,这工作正常。我没有警告等。
显然,如果模拟器中没有原始图像,我无法显示所选图像或对所选图像执行任何操作,因为我不知道它是什么。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在运行 4.0(3GS)的设备上运行并遇到同样的问题。以前也运行得很好。所以这不是模拟器错误。然而对我来说,这似乎只有在用户创建的相册时才会发生。如果从相机胶卷中选择或用相机拍摄,则效果很好:/。
如果我找到解决方案(现在正在研究)将发布。
更新:这似乎是苹果的一个错误,因为正如我们都指出的那样,返回的信息字典仅包含媒体类型的键值对,即使该值是“public.image”,它也不会返回该图像在 UIImagePickerControllerOriginalImage 键中,因为它应该。我已提交错误报告,错误 ID# 8176175。
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.
我也得到了这个,但如果你选择这个,你会同时得到它们(现在看起来像是一个解决方法):
self.imagePicker.allowsEditing = YES;
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;