适用于iOS的ImagePickerController

时间:2015-02-18 02:57:37

标签: ios uiimagepickercontroller

我正在尝试从设备的照片库中选择一张照片。 到目前为止这是我的代码。我正在关注一个教程,这应该可行,但我收到一个错误:

"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];

    }

1 个答案:

答案 0 :(得分:1)

info更改为editInfo即可解决此问题。