简体   繁体   English

Swift 3 tableview 标题自定义单元格

[英]Swift 3 tableview header custom cell

I had a custom cell being used as a tableview section header.我有一个自定义单元格用作 tableview 部分标题。 I updated to swift 3 and now it is not showing anymore我更新到 swift 3,现在它不再显示了

func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
    let header = tableView.dequeueReusableCell(withIdentifier: "tableHeader") as! tableHeader

then i put in some constraints and return header然后我加入了一些约束并返回标题

你的自定义类应该从UITableViewHeaderFooterView扩展,它会工作。

I know it's a late answer but for some who did not find the correct answer till.我知道这是一个迟到的答案,但对于一些直到之前才找到正确答案的人来说。 You can use UITableViewSectionHeight.您可以使用 UITableViewSectionHeight。 Below is an example:下面是一个例子:

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    return 80 // this is your row height
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM