UITableViewCell自适应高度

来源:互联网 发布:db2新增字段sql 编辑:程序博客网 时间:2024/05/17 03:09

在设置使用cell高度自适应的时候, 需要注意的地方:
1. cell里面的控件约束, 在竖直方向上必须能连接起来
2. cell里面的控件, 最后一个view需要有bottom的约束
3. 不需要重写tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
4. 需要配置tableView的两个属性( 如下: )

tableview.estimatedRowHeight // 预设高度tableview.rowHeight = UITableViewAutomaticDimension // 自动设置row height

除了cell之外, Footer Header 同理!

0 0
原创粉丝点击