Autosizing UITableViewCells

Here’s another post from the ELCSlider — why yes, it’s in our current project now and working nicely, thank you — guy; how to get your UITableViewCell to autosize itself to the correct number of lines to display text:

Making Smarter Table View Cells

The nifty thing here is that there’s no subclassing or anything weird involved, all it does is calculate the correct number of lines for the text put in your bog standard cell’s textLabel and detailTextLabel at cellForRowAtIndexPath and heightForRowAtIndexPath times. And why yes, indeed the standard cell will draw them in the correct relative positions:


Neat. Wouldn’t have expected it to be that easy, would you? Code is on github, check it out!

Alex | November 18, 2010
  • Ray Wenderlich November 19, 2010 at 11:11 am
    Damn man, don't know how you manage to find all this cool stuff :] Another great catch!

Leave a Reply