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

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.

Related

How to make TableView Header Static/ unScrollable

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:

UICollectionView header view like table view header

Is it possible to create UICollectionView header view like UITableView headerView? I mean header view for whole collection view, not the repeated one for each section.
If that's impossible, then how could I add outlets to section view subviews from Storyboard?
Eventually I put UICollectionView in UITableViewCell and added some code to calculate cell height.

Prevent UITableView from scrolling when section header view is dragged

I have a super-tall (220pt) section header on a table view that shows in app purchase information. When the user drags on the section header, the rows below scroll accordingly. It makes sense with a regular table view but in this case, the behaviour is weird.
Is there any way to prevent this happening? I've tried setting the view to exclusiveTouch = YES and even disabled userInteraction but the tableview insists on scrolling.
I tried overriding beganTouches etc but they still got passed to the table view, so in the end I abandoned using section header view and inserted the view above the table view. The view had a fixed 220pt height set in the storyboard and an NSLayoutConstraint as IBOutlet so its height could be set to 0 when the view was to be hidden.

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.

UITableView header that stays at top

I'd like to have a tableview header that can remain at the top of the table, even when the user has scrolled down. I tried using a section header for this, but my table has multiple sections so I can't guarantee that one particular header will be at the top.
What should I do?
From your parent view, add the table view and a separate "header" view. Position the table view origin below the header view's origin.

Resources