Martin Lang
Martin Lang

Reputation: 831

UILabel not displaying words after line break

I'm displaying a UILabel inside a UITabelViewCell - and I am trying to get the overflowing text to the next line. This worked fine, when I used the "Title" ProtoType Cell - but since I switched to a Custom Cell with one UILabel (So i can adjust the width of UILabel) things seem a bit broken.

Answer (Provided by Jack Wu): Label too small to hold 2 rows.

This is what I'm doing, and how I am trying to set the Line Break:

UILabel *label = (UILabel *)[cell viewWithTag:200];

[label setLineBreakMode:NSLineBreakByWordWrapping];
[label setNumberOfLines:0];

This is how my IB looks like: enter image description here What happens: The Text is being cutoff at the width of the label - but no linebreak is happening. This is how it looks (see the Cells with the trailing ,, those are cut off) enter image description here

What am I missing here?

Edit: Using [label sizeToFit] results in following:

enter image description here

Upvotes: 1

Views: 3885

Answers (2)

Jack
Jack

Reputation: 16855

Edit2: It looks like your label is too small for the text. You could try resizing the height of the label to accommodate multiple lines of text

Old Answer ---

Edit: Looking at your response to the other solution, it looks like the label is line breaking properly but the text is too big for the label.

There could be a few issues

  1. Is there a "..." appearing in your label? If so, the line break mode is not set properly.

  2. It may simply be that your label is too small to hold the text. You need to allow the label to shrink the text automatically or increase the size of the label

    //iOS 7 
    label.minimumScaleFactor = 0.5 // Scales the text down
    //iOS 6 and prior
    label.minimumFontSize =  8 // Or whatever font point
    

Upvotes: 2

Rubycon
Rubycon

Reputation: 18346

try to use this line

[label sizeToFit];

Upvotes: 0

Related Questions