How to set dynamic cell height based on content

I have an application that requires user comments to be displayed in a table cell. How to set dynamic cell height based on cell content like in Instagram?

enter image description here

Basically, I have texts and comments that have different lengths in different cells. Can someone advise me how can I implement a dynamic height method (like instagram)?

+8
ios objective-c uitableview
source share
4 answers

Check out the UITableViewDelegate documentation .

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

Remember that you cannot reference the cell of this method, so you want to calculate the height of the content separately and use it to generate the height.

+19
source share

Combine my dynamic label here with my dynamic table cell height here . The perfect combination!

+3
source share

You should look at the 3D source code of the library , which offers complex cells as you want. This may give you answers to the question of how to do this, even if you are not going to use it:

three20 cells

+1
source share

You should address this question. The answer is here.

Dynamic height of UITableView in UIPopoverController (contentSizeForViewInPopover)?

+1
source share

All Articles