TechChain
TechChain

Reputation: 8944

Calculate height of tableview cell according to height of tableview height inside cell?

I have a table view.I has one custom cell in it.In that custom cell i have a UITableView.This child tableview can have cells & their content height can be dynamic.So i want calculate height of each cell & multiply the no of cells.After that height which is calculated give height to the main cell.

I wil use below logic

**Total height of main cell = height of each cell in child tableview * no of cells + header** 

but i don't know how to do it.Please guide me how can i do this

Upvotes: 1

Views: 163

Answers (1)

KKRocks
KKRocks

Reputation: 8322

Try this

[tableView reloadData] ; 
 CGSize tableViewSize= tableView.contentSize; // here you get your tablview's total height

Get parent cell for your tableView

   UITableViewCell *parentCellcell =(UITableViewCell *)tableView.superview.superview; // track your cell
   if (parentCellcell){
        NSIndexPath *indexPath = [tblViewParent indexPathForCell:cell];
    [tblViewParent reloadRowsAtIndexPaths:[NSArray 
           arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone];
   }

Upvotes: 0

Related Questions