我有以下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