On multiple occasions I needed to display multi-line text in a UITableViewCell. For example to display an address I would prefer to use a single cell with multiple lines of text, like the Contacts app does.
Previously I would always create custom UITableViewCell subclasses. Thankfully Ahmed Abdelkader found out how to configure a default cell to display multi-line text without any subclassing.
To create a cell similar to the one in the Contacts app:
1 2 3 4 5 6 7 8 9 10 |
|
Make sure the table view also knows about the correct height.
1 2 3 4 5 6 |
|
The formula 44.0 + (numberOfLines - 1) * 19.0
is derived from measurements on cells with different number of lines in the Contacts application.
(via)