Section Header of UITableview not pin at the top when scroll up - Swift - swift

Normally, When I create table with style grouped, there are no any problem with section header. when I scroll up, the section header always stay at the top even when scroll pass it. I create one sample tableview using group style, section header not stay at the top when I scroll up like before. maybe do I miss some properties?.

Make sure style is set to Plain not Grouped.
Check below image:

Related

how to make a sticky headerTableView while having numerous headers in sections?

A goal of mine is to have an appearing/disappearing headerTableView - show on scroll up, hide on scroll down. I have tried setting tableView style to plain but then my section view headers are sticky and not just the headerTableView. Does anyone have an idea how to have an always showing/disappearing headerTableView regardless of scroll position (not just when I'm on top)?

Swift: UITableView scrolls back to top when section header height is changed dynamically

!
I have a tableView with a single section. The header of this section holds the Sort By label and the three ImageViews. The view below it is a UITableViewCell.
The first image shows the initial view of the section header. When the header is clicked (have added a tap gesture), I expand the section view by changing the constant of the height constraint programmatically (have created an outlet for the height constraint).
Everything works fine, the section header expands as desired. However the tableviewcell scrolls right to the top again. Meaning, if when the section header was not expanded and I had scrolled down to some level, as soon as the header view expands, the entire offset is lost and tableviewcell scrolls right back to the top. I do not want this. I want the table view cell to remain where it is and for the section header to expand and collapse over it. How can I achieve this? Please help.
it sounds like you might be doing this:
setContentOffset(CGPointZero, animated: true)
which you shouldn't do.

Plain UITableView with Grouped cells

I'm trying to create a UITableView with headers that behave like a Plain UITableView (i.e. the float at the top until they are displaced by the next header and so on...
But the cells themselves will have a Grouped look to them.
I've set the TableViewStyle to UITableViewStylePlain to get the correct behaviour of the header.
Now, I'm thinking my only option is to create images to use as the background of my own custom cells.
I will need a top, bottom, middle and single image that will have rounded corners to cover all the possibilities.
Is there another way of doing this?
You already wrote option A). You can also go the opposite way (without the need of images, but some more logic):
Use UITableViewStyleGrouped
Add one floating header view as a seperate view on top of the tableView
Set the UITableViewDelegate
Setup the header views via the delegate
Use scrollViewDidScroll: (the tableView delegate also delegates the scrollViewDelegate) and check which section is the top most section currently, update the floating header to its contents and update the position of the floating header to scrollView.contentOffset

Any way to make table view section title line fixed

As shown in pic, when trying slide table up, section title B line will move up as well, but will keep on top of screen until next section title line arrive to top of screen.
Is there anyway to let the section title line move as normal table cell, don't stay on the top of screen until next section title line arrived?
I dont know of how you would do this using the normal sections, you could fake it by adding extra cells to the table view which represent section headers though
There's an answer for this already here:
Change Default Scrolling Behavior of UITableView Section Header
Basically, use grouped style for the table and then provide your own UIViews for the table headers and cells to customise the look of them.

Why don't the header views that are returned from viewForHeaderInSection scroll with the rest of the table?

I just implemented the UITableViewDelegate::viewForHeaderInSection method to return a custom view. However, when I run the app and load the table view, I notice that header view remains stationary while the rest of the table cells scroll underneath it. What gives? How do I get it to scroll with the rest of the table?
Thanks for your wisdom!
That's how it's meant to work. The header for a section will stay at the top of the tableview to give the user a sense of which section she is currently in. Then when she scrolls further down into the second section, that section header scrolls into view and then eventually replaces the first section header at the top.
You can see this in the Contacts app on your phone.