ios - uitableviewcell 的文本位于剖面 View 下

标签 ios swift uitableview

我就遇到过这样的问题。文本我的单元格爬行在表格部分下,成为谷歌但找不到解决方案。在做这些事情之前,当时我只是 UITableViewController,没有段等额外元素。一切都很完美。告诉我如何解决这个问题。谢谢!

enter image description here

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/

相关文章:

objective-c - 如何在NSString中使用文本和变量的组合?

swift - 在 Swift 3 中强制执行特定的初始化程序

ios - UITableView 刷新时无法滚动

ios - 快速功能完成

ios - 如何使用 UITableView 作为 TextField 输入 View

ios - Objective-c 方法调用将引用传递给调用者

ios - TableViewCell 颜色问题

iOS:调整 UIWebView 的高度 - 奇怪的行为

ios - 核心数据 : Parent context and change propagation

ios - 使用空值填充 NSString