Swift dynamic table cell height [duplicate]

99封情书 提交于 2019-11-27 21:52:42

You should use UITableViewAutomaticDimension provides a solution for displaying dynamic content.

Use below code in viewDidLoad:

tableView.estimatedRowHeight = YourTableViewHeight
tableView.rowHeight = UITableViewAutomaticDimension

Read more from here

Hope it helps. :)

Ankit Kushwah

make sure UILabel height constraint not to be constant, if constant it have to set Relation greater than or equal to from attribute inspector

make sure UITableViewestimate row height set as per your.

self.TableName.estimatedRowHeight = 85

and write in UITableViewCell class

 Cell.lbl_name.sizeToFit()


 Cell.lbl_name.numberOfLines = 0

Make sure your UITableViewDelegate method

func tableView(tableView: UITableView,
    heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{

 return UITableViewAutomaticDimension
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!