I want dynamic get uitableview total height,not UITableViewCell
, not frame, and i find self.tableView.contentSize.height=0
for the first time, so i am very trouble in this problem,i need help please.
thanks...
Image view without an image selected has no intrinsic content size, hence we need to set an explicit height constraint for it. The key to achieve dynamic height table view cell is to let Auto Layout know how to calculate the height of the cell.
You need the cell for a certain IndexPath to calculate its bounds. You can do it this way in any of the delegate functions of the UITableView : let row = tableView. cellForRow(at: indexPath) let cellHeight = (row?.
A table view displays a single column of vertically scrolling content, divided into rows and sections. Each row of a table displays a single piece of information related to your app. Sections let you group related rows together. For example, the Contacts app uses a table to display the names of the user's contacts.
You can use contentSize property of UITableView, but you should layout tableView first. Check this answer https://stackoverflow.com/a/2528123/1158590
The self.tableView.contentSize.height
is the proper way to do it, but you have to load the table view before calling this, so put a [tableView reloadData];
before calling self.tableView.contentSize.height
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With