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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:02:36+00:00 2026-06-03T14:02:36+00:00

I just ran into to strange problem, I have a custom tableview cell with

  • 0

I just ran into to strange problem, I have a custom tableview cell with a dynamic height.
While testing this all seemed to work fine, but now that I’m loading real content into it there seem to be some problems.

It appears that some text doesn’t trigger a new line in a UILabel

Correct: http://dl.dropbox.com/u/274185/Screen%20Shot%202012-05-09%20at%201.15.21%20PM.png
Wrong: http://dl.dropbox.com/u/274185/Screen%20Shot%202012-05-09%20at%201.15.30%20PM.png

As you can see in the wrong example, the text is pushed to the second line, but the height of the label still only counts one line.

item.project = @"Another Test Project With Longer Title (Admin / Project Management)";

item.project = @"Test Project (Admin / Project Management)";

The way I calculate the height is like this:

// when creating the cell
cell.projectLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.projectLabel.numberOfLines = 0;
[cell.projectLabel sizeToFit];

// in heightForRowAtIndexPath()
CGSize projectHeight = [item.project sizeWithFont:[UIFont boldSystemFontOfSize:13.0f] constrainedToSize:CGSizeMake(320.0f, CGFLOAT_MAX) lineBreakMode: UILineBreakModeWordWrap];

I tried changing the lineBreakMode, but this doesn’t seem to help much

EDIT:
It appeared to be a problem when calculation the height of the text, I used a fixed 320 points, which isn’t correct, after using the actual width the height was calculated correctly.

CGSize projectHeight = [item.project sizeWithFont:[UIFont boldSystemFontOfSize:13.0f] constrainedToSize:CGSizeMake(cell.projectLabel.bounds.size.width, CGFLOAT_MAX) lineBreakMode: UILineBreakModeWordWrap];
  • 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-03T14:02:37+00:00Added an answer on June 3, 2026 at 2:02 pm

    I believe that sizeToFit only sizes the view down.
    You should set the frame of your label to be high enough for two lines and then call sizeToFit. That will shrink the label when the text is only one line but keep its height when the text is two lines.

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

Sidebar

Related Questions

We have a website and we just ran into a problem when trying to
I just ran into a difficulty while learning Scala. I have an inheritance hierarchy
I just ran into a problem while developing a login system. I build a
(this is regarding the Ramaze.net framework) I ran into some really strange problems while
I've just started with opengl but I ran into some strange behaviour. Below I
I just ran into a problem with the version of JAX-WS in JDK 1.6.0
I just ran into a problem.. I'm trying to build a website at the
Ok, so I just ran into the following problem that raised an eyebrow. For
Ran into a strange problem in PHP today and I'm wondering if someone can
While writing a post about project euler's 14th problem I ran into a difference

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.