Calculate dynamic height of uitableviewcell

I'm searching too many questions related to increasing height of UITableViewCells but I can't get exactly what I want.

I have to calculate dynamic height of UITableViewCell. But, problem is in my cell there is a dynamic number of buttons, ranging from 1 to 100. I don't know how many buttons will show beforehand. So how can we calculate the height?


ANSWERS:


One way you could do is that you can have a global variable, for ex: cellHeight, and then change the cellHeight dynamically when you are customising your cell.

finally, return the cellHeight

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return cellHeight;
}`

There are Two Way for get size of UITableViewCell

1) cell.bounds.size.height 
2) cell.contentView.frame.size.height

It depending on which you actually need.



 MORE:


 ? UITableViewCell dynamic height programmatically
 ? Dynamic UITableCellView height
 ? Dynamic UITableCellView height
 ? Dynamic UITableCellView height
 ? Dynamic UITableCellView height
 ? Dynamic UITableCellView height with cell indicator
 ? Dynamic UITableCellView height with cell indicator
 ? UITableView dynamic cell height breaks on transition or rotation
 ? UITableViewCell dynamic height breaks after insert row
 ? iOS8 implementing heightForRowAtIndexPath with dynamic heights