gpt4 book ai didi

ios - 为什么 UITableView 根据其默认 rowheight(44) 而不是自定义 rowHeight 来计算其 contentSize

转载 作者:行者123 更新时间:2023-11-28 07:56:14 26 4
gpt4 key购买 nike

问题是:

如果您有 20 个单元格并设置 tableView.rowHeight = 60,并且在 tableView 加载其数据后,其 contentSize44*20=880 不是 20*60=1200

如果我想要 contentSize1200,我应该怎么做

最佳答案

首先,您应该在 viewDidLoad() 中设置 rowHeight,如下所示:

tableView.rowHeight = 60

然后在cellForRowAtIndex()中,写一个打印语句确认如下:

print("tableViewContentSize = \(tblView.contentSize)")

你会在滚动 tableView 时得到 contentSize = 1200

希望对您有所帮助!

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com