簡體   English   中英

Swift 3 tableview 標題自定義單元格

[英]Swift 3 tableview header custom cell

我有一個自定義單元格用作 tableview 部分標題。 我更新到 swift 3,現在它不再顯示了

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

然后我加入了一些約束並返回標題

你的自定義類應該從UITableViewHeaderFooterView擴展,它會工作。

我知道這是一個遲到的答案,但對於一些直到之前才找到正確答案的人來說。 您可以使用 UITableViewSectionHeight。 下面是一個例子:

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