Search code examples
objective-cxcodeuitableviewtextlabel

textLabel in a UITableViewCell two+ lines (no cutoff)


I have a RSS feed reader app which each cell collets a title from an element in an XML from RSS feed apple website. Now the titles are very long so what I wanted to do was increase the size of the each cell using:

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

return 80;
  }

to make the title come in two or more lines and spread out but the text continues to go on straight and cut off. How can i fix this?


Solution

  • It's as simple as setting the numberOfLines property on the UILabel and the lineBreakMode property to allow the UILabel to auto-support multiple lines of text.