简体   繁体   中英

Swift 3 tableview header custom cell

I had a custom cell being used as a tableview section header. I updated to swift 3 and now it is not showing anymore

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. Below is an example:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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