I have following code of cellForRowAtIndexPathmethod:
- (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;
}
Where arrayOfChampionNames is local database stored in NSMutableArray that contains pictures names. It’s about 103 cells with images in my UITableView. It lags at first scroll from beginning to end, after that it’s scrolling smoothly. There’s no lags on simulator.
Possible solutions I came up with, but i don’t know how to realise them
- Load images after scrolling,
- Preload image data into UITableView.
You forgot something:
This way you’ll actually utilize the reusable identifier that you created.