gpt4 book ai didi

ios - UITableViewController 部分页眉和页脚未显示

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

swift 3、XCode 8.3动态原型(prototype)细胞。 View (class CustomTableViewController: UITableViewController)在一个单独的 Storyboard 中,该 Storyboard 从另一个 Storyboard 中引用,并带有来自表格的 segue,该表格本身嵌入在 Nav Controller 中。

实现了以下方法:

override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView?
override func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int)

如果我在 navcontroller 中嵌入 viewcontroller,viewForFooterInSection 将被调用并且 View 将可见。 willDisplayHeaderView 仍然没有被调用。 编辑:它不是嵌入,而是将我的 CustomTableViewController 设置为初始 View Controller 。当 Nav Controller 是 IVC 时调用 viewForFooterInSection,当 CustomTableViewController(嵌入在 Nav Controller 中)是 IVC 时不调用 viewForFooterInSection。

如果我将表格更改为静态单元格,willDisplayHeaderView 将被调用并且 viewForFooterInSection 将被调用,但只有当 View 嵌入导航 Controller 时才会再次调用。

嵌入另一个 Nav Controller 会产生我试图避免的副作用,但在任何情况下都不会调用 willDisplayHeaderView

最佳答案

你忘记了这些代表:

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

override func tableView(_ tableView: UITableView, estimatedHeightForFooterInSection section: Int) -> CGFloat {
return 100
}

标题相同。编码愉快!

关于ios - UITableViewController 部分页眉和页脚未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45290934/

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