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 6059673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:44:16+00:00 2026-05-23T08:44:16+00:00

I have the following code that just creates a custom UITableViewCell. I am creating

  • 0

I have the following code that just creates a custom UITableViewCell. I am creating a dynamic row height, is that expensive? Any way to optimize that?

I am also resizing the frame of one of my labels in cellForRow. Is there any way to optimize that as well?

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MessageCell *cell = (MessageCell*)[self tableView:tableView cellForRowAtIndexPath:indexPath];
    return cell.bodyLabel.bounds.size.height + 30;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"MessageCell";

    MessageCell *cell = (MessageCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[MessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    cell.usernameLabel.text = [[items objectAtIndex:indexPath.row]valueForKey:@"user_login"];
    cell.bodyLabel.text = [[[items objectAtIndex:indexPath.row]valueForKey:@"body"]gtm_stringByUnescapingFromHTML];
    [Utils alignLabelWithTop:cell.bodyLabel];
    cell.dateLabel.text = [Utils toShortTimeIntervalStringFromStockTwits:[[items objectAtIndex:indexPath.row]valueForKey:@"created_at"]]; 
    [cell.avatarImageView reloadWithUrl:[[items objectAtIndex:indexPath.row]valueForKey:@"avatar_url"]];

    return cell;
}
  • 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-05-23T08:44:17+00:00Added an answer on May 23, 2026 at 8:44 am
    • Dynamic row height is expensive, because it cannot cache the rendered views efficiently, as the runtime doesn’t know what height you’re going to return for a given cell until it makes the call. Get rid of that if at all possible. I was told by Apple Engineers that it’s more efficient to draw all the cells a little taller than necessary to account for a few larger rows, than to use dynamic height.
    • Cache the object returned by [items objectAtIndex:indexPath.row]
    • I don’t know enough about your cell.avatarImageView, but if it isn’t doing some caching of the image based on the URL, it’s going to be calling out to the internet or filesystem to reload that image every time the cell is displayed. Try the EGOImageView stack, it caches it’s image efficiently, and is some pretty slick code.
    • While you’re in the EGO github code, grab their EGOCache and use it to cache some of the other values you have to parse, such as the bodyLabel text
    • If any of your views on that cell are transparent, watch the WWDC 2011 video on UIKit performance. They have a much more efficient method to draw transparency on tableview cells
    • Why are you changing the positioning of a label on the fly – the call to [Utils alignLabelWithTop:]?

    Also watch the WWDC video on using instruments, they go over how to find where drawing code is killing performance. This year had some (some, not all) really great sessions.

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

Sidebar

Related Questions

I have the following code that won't compile and although there is a way
I have the following code that creates two objects (ProfileManager and EmployerManager) where the
I have the following code that shows either a bug or a misunderstanding on
I have the following code that sets a cookie: string locale = ((DropDownList)this.LoginUser.FindControl(locale)).SelectedValue; HttpCookie
I have the following code that I need to add an additonal object to
I have the following JQuery code that worked perfect in C#/Asp.net 2.0 to call
I have the following html.erb code that I'm looking to move to Haml: <span
I have the following snippet of code that's generating the Use new keyword if
I have several blocks of the following code that each use there own matrix.
I have the following code in an Autofac Module that is used in my

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.