tableview

作者: 花开半夏又一年 | 来源:发表于2023-05-05 10:32 被阅读0次

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

      本文链接:https://www.haomeiwen.com/subject/qhvlrrtx.html