我正在尝试查看以前在ImagePickerView中选择的图像...
这是我的代码
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
coffeeObj.coffeeImage=[image copy];
// imagePreview.image= coffeeObj.coffeeImage;
[imagePreview setImage:coffeeObj.coffeeImage];
[picker dismissModalViewControllerAnimated:YES];
}
显然,coffeeObj.coffeeImage是一个UIImage变量,但根本不起作用...... 但是如果我在这个函数中创建一个新的UIImage变量,那就完美了。 我可以写coffeObj,因为如果我这样做:
coffeeObj.name=@"Ciao";
我查看变量名称已更改。
有什么想法吗? 感谢
答案 0 :(得分:0)
尝试使用此方法:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
coffeeObj.coffeeImage=image;
imagePreview.image= coffeeObj.coffeeImage;
[picker dismissModalViewControllerAnimated:YES];
}
不推荐使用其他方法。
答案 1 :(得分:0)
检查Coffee
类的接口声明,并确保将coffeeImage
存储为强引用
@property (nonatomic, strong) UIImage *coffeeImage;