Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 将图像从sql数据库加载到tableview单元格_Iphone - Fatal编程技术网

Iphone 将图像从sql数据库加载到tableview单元格

Iphone 将图像从sql数据库加载到tableview单元格,iphone,Iphone,在这里,我得到了正确的单元格数据和细节文本标签,但图像视图没有出现,它需要一些其他图像。如果有人能提出建议 从数据库中检索图像作为NSData,然后使用此NSData对象初始化图像对象 ContactInfo *data = [self.contacts objectAtIndex:[indexPath row]]; cell.textLabel.text = data.name; cell.detailTextLabel.text = data.designation; cell.acces

在这里,我得到了正确的单元格数据和细节文本标签,但图像视图没有出现,它需要一些其他图像。如果有人能提出建议

从数据库中检索图像作为NSData,然后使用此NSData对象初始化图像对象

ContactInfo *data = [self.contacts objectAtIndex:[indexPath row]];

cell.textLabel.text = data.name;
cell.detailTextLabel.text = data.designation;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;


NSString *filePath = [[NSBundle mainBundle] pathForResource:data.image ofType:@"png"];

NSLog(@"%@",filePath);

UIImage *image1 = [UIImage imageWithContentsOfFile:filePath];
cell.imageView.image = image1;

return cell;
现在将此图像对象用作

  NSString *filePath = [[NSBundle mainBundle] pathForResource:data.image ofType:@"png"];
  NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:filePath]];

  UIImage *itemImage=[[UIImage alloc]initWithData:imageData cache:YES] ;
有关更多信息,您可以按照

cell.imageView.image = itemImage;