我已经设置了
self.tableView.estimatedRowHeight = 88.0
self.tableView.rowHeight = UITableViewAutomaticDimension
此外,我已将 UILabel
的 numberOfLines 归零。
我没有在 IB 中给出任何固定的高度/宽度限制。
我的 UITableviewCell 高度仍然没有相应地扩展。
请建议我该怎么做。
最佳答案
试试这个:
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
编辑
func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
定义以上两种方法。它解决了问题。
关于ios - UITableview 问题的动态高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37253575/