gpt4 book ai didi

ios - Tableview 页脚不显示

转载 作者:可可西里 更新时间:2023-11-01 00:22:41 33 4
gpt4 key购买 nike

我正在尝试将 TableView 添加到 View Controller 。一切正常,但页脚被隐藏/禁用?我不知道。

我的代码:

private let footerView = UIView()
footerView.backgroundColor = UIColor.Green.color
footerView.addSubview(activityIndicator)
tableView.addSubview(footerView)

tableView.delegate = self
tableView.dataSource = self
tableView.tableFooterView = footerView
tableView.sectionFooterHeight = 20
tableView.footerViewForSection(0)
tableView.tableHeaderView = footerView

当然:

func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? {
return "test.."
}

func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return footerView
}

func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 20
}

我分别尝试了两种实现方式,但没有尝试(仅空白)。

我的页脚 View 是浅灰色的,实现的事件指示器是“不可见的”(框架已设置)

它的 ViewController 和 tableView。

知道为什么页脚 View 不可见吗?

谢谢。

最佳答案

您忘记设置您的footerView 的框架


删除所有代码的第一部分并使用它:

func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView(frame: CGRectMake(0, 0, tableView.bounds.size.width, 20))
}

func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 20
}

关于ios - Tableview 页脚不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37747807/

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