Iphone 将图像从sql数据库加载到tableview单元格
在这里,我得到了正确的单元格数据和细节文本标签,但图像视图没有出现,它需要一些其他图像。如果有人能提出建议 从数据库中检索图像作为NSData,然后使用此NSData对象初始化图像对象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
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;