Reputation: 61
I have TableView
and I set an initial constraint to it as 10.0, for example. Now, I've added 3 cells with the different height sizes(they are autolayout cells), for example, they sizes are (50.0, 120.0, 30.0)
How can I set now my UITableView.heightConstraint = 50 + 120 + 30?
How can I take autolayout cell size? When I try to print their size I get initial size(standard 44.0)
Any ideas?
Upvotes: 3
Views: 6078
Reputation: 76
You can calculate tableviewcell height dynamically.. Try this...
CGfloat height= [self.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height+2;
Upvotes: 0
Reputation: 5149
How about this:
self.tableView.reloadData()
self.tableView.layoutIfNeeded()
self.tableViewHeightConstraint.constant = self.tableView.contentSize.height
Upvotes: 11