Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
243 views
in Technique[技术] by (71.8m points)

ios - Stick UITableView header view to top when creating header in storyboard

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 when scrolling down. If I create my header in code inside of viewForHeader then it does stick.

How can I get my header to stick to the top while scrolling if I create it in storyboard? 2 other askers here and here asked this question and never got an answer.

And yes my UITableView is already plain style, not grouped.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...