我有一個簡單的UIImagePickerController
它試圖搶在原選定的圖像:iPhone 4.0模擬器:didFinishPickingMediaWithInfo丟失UIImagePickerControllerOriginalImage?
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之前,這工作正常。我沒有任何警告等。
顯然,如果沒有模擬器中的原始圖像,我不能顯示或對選定的圖像做任何事情,因爲我不知道它是什麼。
我知道這是幾個月後,但我掙扎着同樣的問題,並發現,雖然它被問了很多次,但它從來沒有回答。那麼,我很高興地說,我已經想出了它,並將它發佈在幾個幾乎相同的問題上,這些問題在搜索中首先出現。我在這裏發佈了完整的答案:http://stackoverflow.com/questions/3088874/didfinishpickingmediawithinfo-return-nil-photo/4192109 – 2010-11-16 07:59:04