0
votes

I have a UITableView with many sections. It is a simple table view. I am using viewForHeaderInSection to create custom views for these headers. So far, so good.

The default scrolling behavior is that when a section is encountered, the section header stays anchored below the Nav bar, until the next section scrolls into view.

My question is this: can I change the default behavior so that the first section header stay anchored at the top for all sections?

Thanks.

Desired Behavior image url:

https://www.dropbox.com/s/2lnspddx02aku1n/scroll.png?dl=0

1
I doubt you'll be able to do this in any straightforward way. You'll probably need to subclass UITableView and add the special first-section-header view as an "anchored" view. - RobP
this might help you. if it does, you can delete this question. stackoverflow.com/questions/5441938/… - danh
@danh I'm hoping that the header view does not scroll up with the rest of view as tableHeaderView does.. - riven
Do you want that first section header to scroll at all? - AdamPro13
@riven, I think what AdamPro13 is getting at is, that if you don't want the section header behavior, and you don't want the tableView header behavior, then maybe what you really want is an independent view that sits over the table. It needn't be related to the table at all. - danh

1 Answers

0
votes

I've done this by augmenting the header/data relationship. You can have a section header on even numbered sections, and data in odd numbered sections.

Example: For section 0, you can show the appropriate heading, but have 0 rows in that section. The data for section 0 should show up in section 1. Section 1 will not have a header. etc etc.