How can I make a multi-line label in a UITableView?

How can we make the text in the table view label go to the next line?

+4
source share
3 answers
//This allows for multiple lines cell.textLabel.numberOfLines = 0; //This makes your label wrap words as they reach the end of a line cell.textLabel.lineBreakMode = UILineBreakModeWordWrap; 

Also, if you want your label to have more space for such a few rows, you should probably allow rows of the table with higher heights. You can do this either by overriding

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

and returns the custom height for each row or by specifying the table rowHeight property, setting the total height of each row.

+27
source

Try adding "\ n" to the label, for example:

 @"Hello,\nworld!" 
+1
source

you can try using the subtitle cell (initWithStyle: UITableViewCellStyleSubtitle). if this is not quite what you want, you can customize your cell by adding a UITextView (or perhaps several UILabels) to it as a subview (s).

0
source

All Articles