How to make TableView Header Static/ unScrollable - ios

I am working on Table View. I have implemented Header at the top of TableView. Its scrolling when i scroll TableView. Any Solution to make the Header Static.

If you want a static header, it means that it should not be a header. The behaviour of a header is to scroll with the UITableView.
You can replace it with an UIView placed above your UITableView.

Also, you can use the UITableView.headerView (UIView?), this is a view placed at the top end of the whole tableView and not per section as the sectionHeaderView.

You can simply add UIView On top of UITableView.
Like this :
And result will be:

Related

How to make header only stick on negative content offset - Swift

I have a tableView and I have a UIView as the tableView header. I want the header to move up the screen when I scroll down and act just like any normal cell. But when I have reached the top of the view, where if I scroll up it will just bounce back, I want the tableView header to stick to the top.
One example is like the Facebook app headers. They scroll when you scroll, but if you're at the top of the page and you scroll up, they wont scroll down, they stay stuck to the top.
How do I achieve this?
If you're using a normal tableView (not grouped style) and you only have one section, you can accomplish this by using the section header instead. The default behaviour of this type of tableView is as you described. You'll just have to provide a custom view for the section header that looks like your cell.
If this isn't a possibility, you'll need to take advantage of tableView being a subclass of scrollView, and implement the scrollViewDidScroll delegate method to check content offsets etc.

How to add a subview to UITableView but not on the header?

I have a UITableView with a custom tableViewHeader.
I want to add a subview (for a loading view), but I do not want to affect the header. It should be added to the section part only, so the controls remains active on the header, while the table reloads.
All the other resources that I found were to add the view to tableview header, or to section's header/footer or cell.contentView.

Swift: fixed searchBar into tableView header

I have a tableView with a searchBar inside the table header.
Everything is working well except when I scroll down the rows, the search bar disappear.
How can I make it fixed?
There is no a way to maintain the header of a tableView fixed, but an useful approach when you need a unique header, could be to use UIViewController instead of UITableViewController, and set the header (UIView that contains searchBar) above the tableView.

UITableView header will not stick to the top of UITableView

I have a UIViewController in my Storyboard and in that I have a UIView which contains a UITableView.
I added another small UIView into the top of the UITableView which contains some buttons and text.
Basically, when the run the app, the UIView which I have placed in the UITableView goes to the bottom of the UITableView for some reason.... It scrolls perfectly with the UITableView, but it stays at the bottom...
How can I get the inserted UIView to stay at the top of my UITableView and still scroll with the UITableView?
Thanks, Dan.
What you're describing is the table view header. You don't add it to the table directly, but rather, you assign it to the table's tableHeaderView property like this:
self.tableView.tableHeaderView = myHeaderView;
Or you can just drag and drop a view into the storyboard at the top of the table view above the first section.

UITableView: anchor section header

I have a UITableView with one section and a header. The problem is that when I scroll down beyond the contents of the table, the header is pulled down along with the cells. I would like it to stay at the top of the view. I tried the suggestion on this post,
Change Default Scrolling Behavior of UITableView Section Header
using the footer of a zero-row section as the header, but it still isn't anchored. Does anyone know how to do this properly?
Are you using a UITableViewController? If you are using a UIViewController that contains a UITableView you could just add a UIView above the UITableView.
You could also add the UIView on top of the UITableView and add an alpha gradient to make it look more similar to a regular UITableView section header.

Resources