gpt4 book ai didi

ios - 如何更改 tableView 页脚中空单元格的高度?

转载 作者:行者123 更新时间:2023-11-28 08:34:26 25 4
gpt4 key购买 nike

我的 tableView 中只有一个 cell。此 cell 具有固定高度。在这个 cell 下,我有很多空单元格,它们实际上不是单元格,而是默认创建的。所有这些单元格都有分隔符,所以不难看出高度。

如何使这些非单元格(位于 tableView 页脚中)的高度与第一个 cell 的高度不同?

我试过使用 heightForRowAtIndexPath

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {

if indexPath.row == 0 {
return 140.0
}
return 70.0
}

但正如我所见,它仅针对真实单元格调用,而不针对 tableView 页脚单元格调用。

最佳答案

我没有为此找到真正的解决方案,所以我想出了创建看起来像单元格的 tableView.tableFooterView

    let unselectedCellHeight = CGFloat(70.0)
let screenHeight = UIScreen.mainScreen().bounds.size.height
let cellsAmount = Int(round(Float(screenHeight/unselectedCellHeight)))
let tableFooter = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: screenHeight))
for i in 1...cellsAmount {
let view = UIView(frame: CGRect(x: 0, y: unselectedCellHeight*CGFloat(i), width: tableView.frame.size.width, height: 1))
view.backgroundColor = UIColor.cellHeaderGrayColor()
tableFooter.addSubview(view)
}
self.tableView.tableFooterView = tableFooter

关于ios - 如何更改 tableView 页脚中空单元格的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38211366/

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