我有以下cellForRowAtIndexPath
方法的代码:的UITableViewController滚动滞后与大量图像
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"champion cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UIImage *cellIcon = [UIImage imageNamed:[arrayOfChampionPictures objectAtIndex:indexPath.row]];
[[cell imageView] setImage:cellIcon];
cell.imageView.frame = CGRectMake(0.0f, 0.0f, 70.0f, 70.0f);
cell.imageView.layer.cornerRadius = 7;
[cell.imageView.layer setMasksToBounds:YES];
cell.textLabel.text = [arrayOfChampionNames objectAtIndex:indexPath.row];
return cell;
}
凡arrayOfChampionNames
存储在NSMutableArray
包含图片名称本地数据库。这是关于我的UITableView中的图像103单元格。它在第一次滚动时从头到尾滞后,然后顺利滚动。模拟器上没有滞后。
可能的解决方案,我想出了,但我不知道如何实现它们滚动后
- 加载图像,
- 预加载图像数据到UITableView的。
您需要重用您的单元格并将图像大小调整为单元格图像视图的大小 - 这可能是您遇到滞后现象的原因。 – sooper
@sooper谢谢你的回应,我会尝试! – ignotusverum