在我的UITableviewCell
带有图片更新之前的一瞬间,它显示了重用单元格的图片。有谁知道解决这个问题的最佳做法?
我尝试了以下方法(但可能实现有误):
prepareForReuse
。我尝试删除图片,但旧图像仍然短暂出现,但仍然闪烁(如果有人认为我拼错了,并且应该可以工作,我可以重写代码并发布)图像加载代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
UIImageView *pictureImageView = (UIImageView *)[cell viewWithTag:8];
//Using AFNetworking
[pictureImageView setImageWithURL:pictureURL];
return cell;
}
最佳答案
解决方案不是在单元格出现时尝试更改图像,而是在单元格消失之前隐藏旧图像,然后再使用。有一种方法可以做到这一点:
-(void) tableView:(UITableView *)tableView didEndDisplayingCell:(BigPictureCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
UIImageView *pictureImageView = (UIImageView *)[cell viewWithTag:8];
pictureImageView.image = nil;
}
关于ios - 滚动后可重用的UITableViewCells更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21832061/