UITableViewCell with a multiline UILabel

I am playing with the iPhone UIKit to understand what I can do before starting some little projects. In one of my project idea I want to have a multiline cell in a UITableView. I look around on the web, found different solution. Here is the simplest I found: iProgrammer Tip #3: Multiline text in UITableViewCell (without custom view) by Prakash.

As explained in Prakash post there is two steps to set up a multiline cell.

  1. calculate the height of the cell through heightForRowAtIndexPath from UITableViewDelegate Protocol (I will not copy and past Prakash post).
  2. In is post Prakash create a new UILabel, setup it so it support multiline text and add it to the cell. But it seems we can simply use the existing UILabel from UITableViewCell. So I just avoid of creating a new label.

Here is a project showing how I did it : SampleMultiLineUITableViewCell. To create this project I use the Navigated-based Application XCode template.

Leave a Reply