【发布时间】:2014-12-25 14:28:34
【问题描述】:
我有 tableview,我想显示目录内一个文件夹中的所有图像,并且我有该目录的路径。我正在将图像加载到单元格中:
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
for (UIView * view in cell.contentView.subviews){
if ([view isKindOfClass:[UIButton class]]) {
[view removeFromSuperview];
}
}
cell.imageView.image = nil;
cell.accessoryType = UITableViewCellAccessoryNone;
NSData *imgData = [NSData dataWithContentsOfFile:absoluteImagePath];
UIImage *thumbNail = [[UIImage alloc] initWithData:imgData];
UIImageView *imageView = [[UIImageView alloc] initWithImage:thumbNail];
[cell insertSubview:imageView atIndex:0];
}
但是当我向上和向下滚动时,我会在单元格内的图像上显示图像(旧图像在新图像下方可见,例如当我滚动到第一个位置时,我会在其他图像下方看到索引 0 的图像)。 有谁知道有什么问题,我是这个 iOS 编程的新手?
【问题讨论】:
标签: ios objective-c ios7 ios8