问题是:
如果您有20个单元格并设置了tableView.rowHeight = 60,并且在tableView加载其数据后,其contentSize44*20=880而不是20*60=1200
如果我想要contentSize1200我该怎么办

最佳答案

首先,应按如下方式在viewDidLoad()中指定行高:

tableView.rowHeight = 60

然后在cellForRowAtIndex()中,编写一个print语句来确认以下内容:
print("tableViewContentSize = \(tblView.contentSize)")

在滚动tableView时,将得到contentSize=1200
希望对你有帮助!

关于ios - 为什么UITableView根据其默认rowheight(44)而不是自定义rowHeight计算其contentSize,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48001182/

10-12 05:12