tableview

tableview自适应高度


functableView(_tableView:UITableView,heightForRowAt indexPath:IndexPath)->CGFloat{switchindexPath.section{case0:return250default:returnUITableView.automaticDimension}}

方法二:

functableView(_tableView:UITableView,estimatedHeightForRowAt indexPath:IndexPath)->CGFloat{//数值为预估高度,随便写影响也不大return250}

方法三:

tableView.rowHeight=UITableView.automaticDimension//或者下面的方法(数值为预估高度,随便写影响也不大)tableView.estimatedRowHeight=250

使用方法一的好处是:可以固定某一行高度

而方法二、三的所有行高都由系统自动计算

作者:分享学习

链接:https://www.jianshu.com/p/49e2a6163e23

来源:

著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

你可能感兴趣的:(tableview)