我用这种方式调用UIImagePickerController:
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:imagePicker animated:YES];
并希望获得使用此委托方法挑选的图像:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo
问题是editInfo NSDictionary等于nil everything
答案 0 :(得分:1)
如果你跳转到你正在使用的方法的定义(CMD +点击),它会说 - “__ OSX_AVAILABLE_BUT_DEPRECATED”:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:
(UIImage *)image editingInfo:(NSDictionary *)editingInfo
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA,__MAC_NA,__IPHONE_2_0,__IPHONE_3_0);
使用:
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
[self dismissModalViewControllerAnimated:YES];
//This if statement is just to make sure we did receive an image and not
//a video or whatever
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
UIImage * pickedImage = [info objectForKey:UIImagePickerControllerOriginalImage]];
}
}