我就遇到过这样的问题。文本我的单元格爬行在表格部分下,成为谷歌但找不到解决方案。在做这些事情之前,当时我只是 UITableViewController,没有段等额外元素。一切都很完美。告诉我如何解决这个问题。谢谢!
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell = tableView.dequeueReusableHeaderFooterViewWithIdentifier("CommonSectionTableView") as! CommonSectionTableView
cell.titleLabel.text = self.ordersSectionName[section]
return cell
}
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 55.0
}
最佳答案
试试这个代码......
//If you want to place a header
let header = "Your Header Name"
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return header
}
//If you using section header
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "Section \(Your Section Name or Array)"
}
上面的代码会将 headerView 放在 tableView 的上方...
如果您想自定义 headerView,请检查以下问题
How can we add image in UITableView section header using swift?
Customize UITableView header section
http://www.ioscreator.com/tutorials/customizing-header-footer-table-view-ios8-swift
关于ios - uitableviewcell 的文本位于剖面 View 下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40050713/