Reputation: 831
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.
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:
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)
What am I missing here?
Edit: Using [label sizeToFit]
results in following:
Upvotes: 1
Views: 3885
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
Is there a "..." appearing in your label? If so, the line break mode is not set properly.
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