Stick UITableView header view to top when creating header in storyboard

前端 未结 2 1209
野性不改
野性不改 2020-12-11 07:08

I have created a table view header using the answer here.

My problem is that when creating the header this way, it does not \"stick\" to the top of my UITableView wh

2条回答
  •  既然无缘
    2020-12-11 07:25

    rdelmar's comment helped me understand the reasoning behind it not working. Here is what I did in practice to fix the problem:

    I had to drag the header view in storyboard down by where the first responder is. You'll notice you can't actually drag the header view down on the view itself, you'll have to drag the element down from the document outline.

    I also had to implement viewForHeaderInSection (returning the header view that I made an outlet) and heightForHeaderInSection.

    Every time you want to edit the view via storyboard, you'll have to drag it back up to edit it, then drag it back down so it works correctly.

提交回复
热议问题