我正在尝试调用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)
答案 0 :(得分:0)
myImage
为空,因此对它的任何调用都无效,应事先为其分配一些内容(myImage = ...
或self.myImage = ...
)