我正在尝试从设备的照片库中选择一张照片。 到目前为止这是我的代码。我正在关注一个教程,这应该可行,但我收到一个错误:
"Use of undeclared identifier info", on the second method, line 3.
我做错了什么?
- (IBAction)selectPicturePressed:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:NULL];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo
{
UIImage *chosenImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
self.imgToUpload.image = chosenImage;
[picker dismissViewControllerAnimated:YES completion:NULL];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissViewControllerAnimated:YES completion:NULL];
}
答案 0 :(得分:1)
将info
更改为editInfo
即可解决此问题。