Abha
Abha

Reputation: 1082

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?

Upvotes: 1

Views: 187

Answers (2)

Burhanuddin Sunelwala
Burhanuddin Sunelwala

Reputation: 5343

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;
}`

Upvotes: 1

iPatel
iPatel

Reputation: 47089

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.

Upvotes: 0

Related Questions