Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7988599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:30:16+00:00 2026-06-04T12:30:16+00:00

I have a custom UITableViewCell that consists of a UIImageView and a UILabel. The

  • 0

I have a custom UITableViewCell that consists of a UIImageView and a UILabel. The cell is 320x104px and the imageView takes up the whole area with the label in front. There are only 8 cells.

in ViewDidLoad I am creating all needed images up front and caching them in a dictionary at the correct dimensions.

When I scroll the UITableView there is a noticable lag every time a new cell is encountered. This makes no sense to me as the image it is using is already created and cached. All that I’m asking of the cell is for its UIImageView to render the image.

I am using a custom cell with its view in a xib and configuring my UITableView to use it with:

[self.tableView registerNib:[UINib nibWithNibName:@”ActsCell” bundle:nil]
forCellReuseIdentifier:myIdentifier];

Cell creation and configuration:

- (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{  
    NSString* reuseIdentifier = @"ActsCell";
    ActsCell* cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    // Configure the cell...
    [self configureCell:cell atIndexPath:indexPath];
    return cell;
}

- (void)configureCell:(ActsCell *)cell atIndexPath:(NSIndexPath *)indexPath 
{
    Act* act = [self.acts objectAtIndex:indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.title.text = act.name;
    cell.imageView.image = [self.imageCache objectForKey:act.uid];
}

What could be causing the lag? There would seem to be no benefit in trying to do anything Async as all the time-intensive work is done.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:30:18+00:00Added an answer on June 4, 2026 at 12:30 pm

    Do you load images from local files by any chance?

    By using Instruments I’ve found that there is some lazy loading mechanism in UIImage – the real image data was decompressed from PNG only at the stage of rendering it on the main thread which caused the lag during scrolling.

    So, after the loading of UIImage with -initWithContentsOfFile: method, I’ve added code to render the contents of this image to offscreen context, saved that context as new UIImage and used it for UIImageView in UITableViewCell, this made the scroll to be smooth and pleasant to the eye again.

    In case of reference there is the simple code I’m using to force reading of image contents in separate thread (using ARC):

    UIImage *productImage = [[UIImage alloc] initWithContentsOfFile:path];
    
    CGSize imageSize = productImage.size;
    UIGraphicsBeginImageContext(imageSize);
    [productImage drawInRect:CGRectMake(0, 0, imageSize.width, imageSize.height)];
    productImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    

    And I think the surface of UIImage created in such a way will be in the supported format suited for rendering, which will also offload work needed to render it on main thread.

    EDIT: The docs for UIGraphicsGetImageFromCurrentImageContext() say that it should be only used from main thread, but searching on the net or SO shows that starting from iOS 4 the UIGraphics.. methods became thread safe.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom UITableView cell that has a UIImageView sized to the width
I have a custom UITableViewCell that contains a UISlider control and a UILabel which
I have a project with a custom UITableViewCell (cell.h/.m/.xib) that has 2 labels (labelMain/labelSub),
I have a custom UITableViewCell that has 2 buttons and a label on it.
I have a custom UITableViewCell that I use like this: AppTableCell *cell = [tableView
I have a UILabel in a custom UITableViewCell that gets resized when the device
i have one tableview that have custom cells and one cell contains uiimageview,uilabels .
I have a custom UITableViewCell that I defined in a storyboard. I added a
Similar to this question I have a custom subclass of UITableViewCell that has a
I have a custom UITableViewCell subclass. I have set the contentView of my cell

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.