How can I create a variable sized UITableViewCell?
myLabel.numberOfLines = 2;
Check the docs for full info on how to use this property.
Tweetero
provides an example of this in MessageListController.m
. The code there renders the following screen:
(Pic is taken from Mashable).
The basic implementation outline:
When constructing a
UITableViewCell
, create and add aUILabel
as a subview in the manner shown intableviewCellWithReuseIdentifier:
. Look for the creation ofTEXT_TAG
label.when enriching the
UITableViewCell
with views, ensure that you format label properly, as is done inconfigureCell:forIndexPath
, similarly look for the label tagTEXT_TAG
.Return the appropriate height for each cell, as is done in
tableView:heightForRowAtIndexPath
.