我想从imagepickercontroller获取图像,但是我的代码没有任何效果
这是代码。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picker dismissModalViewControllerAnimated:YES];
    imageview.image = [UIImage imageNamed:[info objectForKey:@"UIImagePickerControllerOriginalImage"]];

最佳答案

您可以尝试使用此代码访问从选择器返回的图像

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    [picker dismissModalViewControllerAnimated:YES];

    UIImage* originalImage = nil;
    originalImage = [info objectForKey:UIImagePickerControllerEditedImage];
    if(originalImage==nil)
    {
        originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
    }
    if(originalImage==nil)
    {
        originalImage = [info objectForKey:UIImagePickerControllerCropRect];
    }
  //At this point you have the selected image in originalImage
    [self saveImageToDocumentDirectory:originalImage];
}

关于ios - 从UIImagePickerController获取图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7766211/

10-12 19:17