【发布时间】:2010-07-07 15:36:00
【问题描述】:
我有一个简单的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模拟器,info集合只包含:
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 之前运行良好。我没有警告等。
显然,如果模拟器中没有原始图像,我无法显示或对所选图像执行任何操作,因为我不知道它是什么。
【问题讨论】:
-
我知道这是几个月后的事了,但是我在同样的问题上苦苦挣扎,发现虽然在这里被问了很多次,但从未得到回答。好吧,我很高兴地说我想通了,所以我将它发布在搜索时首先出现的一些几乎相同的问题上。我在这里发布了完整的答案:stackoverflow.com/questions/3088874/…
标签: iphone ios-simulator uiimagepickercontroller ios4