UIImagePickerController图像没有变化

时间:2010-10-13 05:27:02

标签: iphone ios uiimage uiimagepickercontroller

我正在使用UIImagePickerController来允许用户从他们的库中选择一张照片。然后我想用这段代码分配所选图像;

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
 UIImage* image = [info objectForKey:UIImagePickerControllerOriginalImage];
 [users_pic_ setImage:image];
 [self dismissModalViewControllerAnimated:YES];
}

但是用户pic永远不会改变。

users_pic_定义为:UIImageView* user_pic_;

有人注意到有什么不对吗?感谢

1 个答案:

答案 0 :(得分:2)

使用此代码 -

// make sure to allocate users_pic_

UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; 
users_pic_.image = image; 
[self dismissModalViewControllerAnimated:YES];