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

  • SEARCH
  • Home
  • 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 7610999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:33:22+00:00 2026-05-31T01:33:22+00:00

Evening, I have several UITableViewCell’s which expand dynamically in height based on the text

  • 0

Evening,

I have several UITableViewCell’s which expand dynamically in height based on the text contained within them, but it appears that once a certain number of characters are entered (although I’ve not yet tested this so I’m not sure it’s the exact cause), the height is then calculated incorrectly.

Here are the relevant parts of my code, with an example string that causes an issue, purposely truncated to 1000 characters (the max length for the field the user can type into):

Objective-C is a reflective, object-oriented programming language that adds Smalltalk-style messaging to the C programming language.

Today, it is used primarily on Apple's Mac OS X and iOS: two environments derived from the OpenStep standard, though not compliant with it.[1] Objective-C is the primary language used for Apple's Cocoa API, and it was originally the main language on NeXT's NeXTSTEP operating system. Generic Objective-C programs that do not use these libraries can also be compiled for any system supported by gcc or Clang.

Objective-C is a reflective, object-oriented programming language that adds Smalltalk-style messaging to the C programming language.

Today, it is used primarily on Apple's Mac OS X and iOS: two environments derived from the OpenStep standard, though not compliant with it.[1] Objective-C is the primary language used for Apple's Cocoa API, and it was originally the main language on NeXT's NeXTSTEP operating system. Generic Objective-C programs that do no

This is from my cellForRowAtIndexPath:..

cell.textLabel.font = [UIFont boldSystemFontOfSize:15];
cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.detailTextLabel.numberOfLines = 0;

I then calculate the cell height using the following:

- (CGFloat)tableView:(UITableView *)t heightForRowAtIndexPath:(NSIndexPath *)indexPath {

NSString *cellLabel;
NSString *cellText;

if (indexPath.section == 0) {
    // This returns a small string such as 'Note'
    cellLabel = [generalDetailsCellsArray objectAtIndex:indexPath.row];
    // This returns the example string posted in the above block
    cellText = [generalDetailsValuesArray objectAtIndex:indexPath.row];
}

--- snip ---

CGSize constraint = CGSizeMake(300.0f, 20000.0f);

CGSize labelSize = [cellLabel sizeWithFont:[UIFont boldSystemFontOfSize:15] constrainedToSize:constraint];
CGSize textSize = [cellText sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:constraint];

return (labelSize.height + textSize.height) + 12;
}

Can anyone see any glaringly obvious mess-ups?

Thanks in advance.

  • 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-31T01:33:23+00:00Added an answer on May 31, 2026 at 1:33 am

    Should anyone else come across this question, don’t make the same mistake as I did!

    CGSize constraint = CGSizeMake(300.0f, 20000.0f) should be CGSize constraint = CGSizeMake(280.0f, 20000.0f), I wasn’t taking in to account the cell padding inside the cell so I was calculating a label width wider than what it was when drawn in to the cell.

    In short: A label inside a grouped UITableViewCell has a 280 width!

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

Sidebar

Related Questions

I have a large makefile which builds several libraries, installs them, and then keeps
I think that I am having a slow evening but I have a question
I have several GAE projects and have no problem uploading them. I am now
Good evening, I have 2 functions and each of them accepts as argument a
Good evening, In my app that I'm currently developing, I have a class that
Good evening I have a JTable that I built with a TableModel how to
Good evening. For a project, I have to create a system. In this system,
Good evening, i need to know how can i have one .h file that
Friends, I am new to lucene full text search. i have developed page with
Evening all. I have the following code that I need looking into - basically

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.