我正在使用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_;
有人注意到有什么不对吗?感谢
答案 0 :(得分:2)
使用此代码 -
// make sure to allocate users_pic_
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
users_pic_.image = image;
[self dismissModalViewControllerAnimated:YES];