无法在UIImageView中更新/设置图像

时间:2012-10-28 01:27:52

标签: uiimageview ios6 uiimagepickercontroller

我正在尝试调用UIImagePickerController并使用它获取的信息来更新UIImageView。我无法从信息中获取UIImage到UIImageView。

- (void)imagePickerController:(UIImagePickerController *)picker
        didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage* originalImage = nil;
    originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
    [myImage setImage:originalImage]; //also tried myImage.image = originalImage

    NSLog(@"originalImage: %@\n", originalImage);
    NSLog(@"userImage.image: %@\n", myImage.image);

    [self dismissViewControllerAnimated:YES completion:nil];

}

当我运行此代码时,UIImageView保持空白。 我得到一个控制台输出:

originalImage: <UIImage: 0x80e0f90>
userImage.image: (null)

1 个答案:

答案 0 :(得分:0)

myImage为空,因此对它的任何调用都无效,应事先为其分配一些内容(myImage = ...self.myImage = ...