更新时间:2022-12-29 22:44:46
如果你需要在运行时定义单元格的高度,你必须实现 UITableViewDelegate
的 tableView:heightForRowAtIndexPath:
方法。这有点痛苦,但这是你能够以编程方式计算单元格高度并在表格需要显示时将其返回到表格的唯一方法。
If you need to define the height of the cell at runtime, you must implement the tableView:heightForRowAtIndexPath:
method of the UITableViewDelegate
. It's a bit of a pain, but it's the only way you'll be able to programatically calculate the height of the cell and return it to the table when the table need to display it.