gpt4 book ai didi

ios - TitleForHeaderInSection 显示不正确

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

此应用仅供研究和学习之用。我是开发新手,所以这没什么特别的,真的。

它应该显示一个包含一些联系人的 TableView,这些联系人分为两个不同的类别:最近和 friend

但是,当我尝试使用 TitleForHeaderInSection 函数返回那些要显示为标题(其他一切都按照我的预期工作)时,最终只显示一个。 (我使用了 switch 函数,所以就此而言,只显示 case 0)。

override func numberOfSections(in tableView: UITableView) -> Int {

return 2 // Recent & Friends

}

override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {

switch section {

case 0: return "RECENT"

case 1: return "FRIENDS"

default: break

}

return String(section)
}

enter image description here

如上面的屏幕截图所示,在应用程序中,只有两种情况之一被返回,我真的很想弄清楚原因。

最佳答案

是否显示部分或部分缺失,而不仅仅是标题?如果部分缺失,那么您需要选择在 Storyboard中分组的表格 View 样式

关于ios - TitleForHeaderInSection 显示不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40894411/

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