views:

39

answers:

3

In a table cell I tried putting "\n" in the text, but this doesn't put the text on a new line it just puts a space in between the text.

A: 

Either use different labels, a different style (there's one style, I can't remember which one, which has two labels, one ontop of the other in terms of vertical space), or create your one label allowing at least 2 lines. Alternatively, you could use a text view instead. Many ways you can do this, even custom drawing the text. Pick your poison.

jer
+2  A: 

You need to set the cell.textLabel.numberOfLines property to something other than 1. 0 means any number of lines, anything higher than 1 means capped at that number of lines. Also note that you'll need to implement the -tableView:heightForRowAtIndexPath: delegate method in order to resize your cells to fit the text, which may be a bit complicated since you won't know the precise metrics the cell uses to lay out the label.

Kevin Ballard
A: 

Set the property cell.textLabel.numberOfLines to 0 lines, this will automatically calculate the number of lines needed to fit the text you have set to the text label.

You should not manually change the frame of the default textLabel of the cell since the frame of textLabel will be calculated intelligently based on whether image is set to the cell's imageView property or not.

Raj