tableView section headers disappear SWIFT

前端 未结 6 1402
慢半拍i
慢半拍i 2020-12-13 18:01

I have a tableView set up so that when a cell is touched, it expands in height to reveal more information. The tableView has 5 sections.

I have a bug: when a cell e

6条回答
  •  借酒劲吻你
    2020-12-13 18:40

    I had the same bug because I was returning a cell using dequeue method instead of a UITableViewHeaderFooterView.

    Solution:

    • Add a view outside of the view hierarchy
    • Set the type to UITableViewHeaderFooterView
    • Customize
    • Link to an @IBOutlet
    • In func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? return the outlet

    Common pitfalls:

    Don't forget to set the header sizes Don't forget to set the outlet as strong.

提交回复
热议问题