I have custom table view cell with images (loaded from app document directory), labels, shadows etc. and when I scroll the table view it causes a lot of lags. How can I avoid these lags? I think it’s possible to cache table view cell, or get a picture of the table view cell, but I don’t know how to implement this. Please, help me 🙂
In cellForRowAtIndexPath: I set the data in if (cell == nil) block, but slowdowns are still there.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
// ...configuring is here...
}
return cell;
}
P.S. Images in cell are high resolution, but reduced to fit…
You should load your images in a background thread. If you’re on iOS 4+, you can use GCD (Grand Central Dispatch) to load these asynchronously.