将下载的图像加载到数组中,并在uitableview中显示



我试图在我的uitableview中添加并显示解析查询中下载的图像,但似乎没有任何功能。这就是我将图像添加到阵列的方式:

 PFFile *image = (PFFile *)[wallObject objectForKey:@"image"];
 UIImage *img = [UIImage imageWithData:image.getData];
 [allImages addObject:img atIndex:0];

这就是我试图在uitableview单元格中显示行的索引路径方法:

   NSData *picData = [allImages objectAtIndex:indexPath.row];
    [(UIImageView *)[cell.contentView viewWithTag:2] setImage:[UIImage imageWithData:picData]];

我不知道为什么它不起作用,任何帮助都将不胜感激!请友善一点,我还是新来的!

allImages数组上添加一个UIImage *对象,然后在配置单元之前从中获取一个NSData *对象。尝试以下操作:

UIImage *image = [allImages objectAtIndex:indexPath.row];
[(UIImageView *)[cell.contentView viewWithTag:2] setImage:image];

最新更新