can I fix section header view not in the top of UITableView - ios

We know that a plain UITableView will fix its section header view in the top of it. Can we make the section header view not to float in the top of its UITableView, but fix in another position, such as 100 points away from the top of its UITableView?
Any ideals will be appreciated,thanks.

You can add custom view as header to your table view & set the position of tableview from it below 100 points.

Sorry there is no any way to stop it.. But You can do this kind of functionality using the UITableViewCell... take the first cell of section to show section detail and set section height as 0..

Related

How to disable the scrolling of table view for first Section #iOS

I have two sections in my table view , I want to have scroll enabled for 2nd section and disabled for 1st section , how could I achieve it ?
A UITableView as a whole is a ScrollView so there is no way to only scroll one section. I'd suggest moving what is in the first section into a UIView, then placing a UITableView below that UIView that just has a single section that contains the views you had in the section of the view.
This way the top part will not scroll, but the bottom part will.
A way to workaround it is having 2 UITableViews, one with scrolling disabled while the other has it enabled.
You can disable scrolling on a UITableView on the Attributes inspector while it's selected. There's a whole section on the Scroll View the UITableView has, and in the second subsection there's a toggle for "Scrolling Enabled" which is on by default.
[Edit: I've just seen the other comment, and I'd still recommend 2 UITableViews if you are dealing with dynamic content. If the content from the 1st section isn't dynamic, you may use an UIView as it'll save a lot of time just by not needing to implement 2 UITableViews in a single UIViewController]
#vinay
Try this solution
Take a view at the top of view controller.
Below that view take tableview.
Set table style to Grouped. It makes sections of tableview scrollable.
In your case I would use Section Header for the second section and make that header as customView.
You need to call the following functions:
1) viewForHeaderInSection
if section == 2 {
... customize your header view
}
2) heightForHeaderInSection
if section == 2 {
... set height
}

How to make section header anchor to the top of a multi section tableview?

I know if set the tableView's type to "Plain" , the section header will automatically anchor on the top of the tableView. but if I have multi sections in the tableView. When the tableView scroll to the next section ,the first section's header will disappear. I hope the first section's header can always anchor on the tableView's top whatever I scroll the tableview to any section. is there any way to do that?
What you describe does not happen for UITableViewStyleGrouped but for UITableViewStylePlain.
I can't really think of any easy way to do what you want - I suspect you'll have to insert your own subview and manage its position according to the table's scrolling position.
I found this article which might have some good ideas for what you're trying to do.

One section of the view controller is still and one section horizontally scrollable

I would like to construct a view controller where one section of the view controller would be still and one section scrollable.
Both sections have headers where as well, one is still and one is moving along with the content in the section.
I do not want the cells in the section to be scrolled separately. All cells should move at the same time along with the header.
I have added an image to make my point little more clearer.
Use UICollection View for both view and disable scrolling for one view and enable scrolling for another view
you can probably add to your UIViewController view a UITableView on the left with fixed size (for example 150px) and vertical scroll disabled and a UICollectionView with horizontal flow and ,if needed a, with custom UICollectionViewLayout (but i think that you just need the classic UICollectionViewFlowLayout) for the right part that fits the remaining space.
Here you can find the component's documentation:
https://developer.apple.com/reference/uikit/uicollectionview
https://developer.apple.com/reference/uikit/uitableview

UITableView with first section header fixed on top

I am developing a table view where the header of the first section of a needs to be fixed at point.
I have set table view style as Plain. The section header is now fixed upto the point where the user scrolls in section 0. As soon as section 1 appears the header also scrolls up. Is there any way that the header of section 0 should always be fixed to the top?
Thanks in advance!
You should add UIView which looks like header and it will be at fix top position and after that view add tableview so when you scroll your UIView will not affected and remains at same position. So, you can manage your stuff like this!

UITableView not scroll first cell

I have two section in my UITabelView. My first cell (in first section) represents some caption. Can I have this cell not move when I scroll UITableView, so other content (cells) will scroll but not first.
No, this isn't supported. Everything in a table view scrolls with the table view. The closest thing resembling what you want is section headers in a plain table. The section header stays at the top of screen as the section scrolls but it stays with its section.
Your only option is to use a UIViewController instead of a UITableViewController. Add your caption view to the top and then add your own UITableView below the caption view. You will need to hook everything up so the view controller works like a table view controller.

Resources