iOS 的 ImagePickerController
ImagePickerController for iOS
我正在尝试 select 设备照片库中的图片。
到目前为止,这是我的代码。我正在学习一个教程,它应该可以工作,但我收到一个错误:
"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];
}
将 info
更改为 editInfo
即可解决。
我正在尝试 select 设备照片库中的图片。 到目前为止,这是我的代码。我正在学习一个教程,它应该可以工作,但我收到一个错误:
"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];
}
将 info
更改为 editInfo
即可解决。