简体   繁体   English

从NSData检索图像

[英]Retrieving image from NSData

I have a view controller that allows me to add a name, image, and date..the name and date are sent back to the table view controller and displayed..I then have a edit view controller that shows when a populated cell is clicked... 我有一个视图控制器,允许我添加名称,图像和日期。名称和日期发送回表视图控制器并显示。然后有一个编辑视图控制器,显示单击填充单元格的时间...

my save method: 我的保存方法:

-(IBAction)save:(id)sender {
  NSData *imageData = UIImagePNGRepresentation(_imageview.image);
  [self.currentPlayer setValue:imageData forkey:@"playerPic"];

 [self.delegate addPlayerViewControllerDidSave];
} 

my delegate is calling the save:&error so i wont paste that code 我的代表正在调用save:&error,所以我不会粘贴该代码

I believe this is working but my question is how do I have that image display on the edit view controller 我相信这是可行的,但我的问题是如何在编辑视图控制器上显示该图像

my name and date information is passing but not the image 我的姓名和日期信息正在传递,但图像未传递

I have a UIImageView and I am attempting something like that but I understand those are two different pointer types and wont work 我有一个UIImageView并且正在尝试类似的操作,但是我知道它们是两种不同的指针类型,无法正常工作

 -(void)viewDidLoad {
 firstnameTextField.text = [self.currentPlayer playerName];
 editImage.image = [self.currentPlayer playerPic];

 }

any help would be appreciated 任何帮助,将不胜感激

您需要从NSData对象创建UIImage,如下所示:

[UIImage imageWithData:[self.currentPlayer playerPic]]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM