iOS UITableView header with sticky menu - ios

I want to create a UITableView with an collapsable view on top and a sticky menu. To show what i exactly mean i made 3 images:
I thought i will make a UITableViewController and place a view above the table but i dont know how to implement the sticky menu.
Whats the best way to accomplish that?

Don't use a UITableViewController, you won't be able to add anything besides the table view.
You should use a standard UIViewController, with a top view housing the sticky menu, and a UITableView below it.
You can open/close the menu by using autolayout: your sticky menu has a "fixed height" constraint, and the table view has no "top" constraint, but a "vertical spacing" constraint between the sticky menu and itself.
Just animate the constant for the "height" constraint of the menu to have a collapse/expand animation.

You should add a table Header for Sticky menu.

Related

Table view header, storyboard, Xcode 11?

In XCode 11,
new storyboard,
add a UIViewController (sic: NOT a table view controller),
hit the + symbol top right,
drag a table view into the view controller.
Perhaps add four constraints so it is simply full-screen.
Table view attributes inspector, perhaps set Prototype Cells to not-zero, say 2.
How do you now add a header view to the table view?
(The header view should (obviously) be able to handle dynamic height content.)
The easy way of to achieve adding HeaderView to UITableView is.
Plus + button from Top Bar and Select an UIView
Then in hierarchy add the exact bottom of the UITableView.
See the image.
Your UIView element must be like that in the hierarchy.
Then the UIView calculations for dynamic view upon to you.
(You can create an IBOutlet of the this UIView and do some calculation in your UIViewController. )

How to adjust the height of my tableView when my dropdown menu is clicked?

I have a implemented a drop down menu above my UITableView and when I click on it I want my table view to go down inside the items of my drop down menu, because right now when I click on my drop down menu, the tableview stay where it is..
i have a view above my prototype cell that contain my drop down menu but I can't put any constraints on it... when I click in "filtre" I want this to happen : image description here
it looks like you added a Table Header view. it is a little different than common UIView.
Instead of changing Height constraints, you'd better to change the frame of the headerview
how-to-set-the-height-of-table-header-in-uitableview
In addition, you can found good codes of dropdown implementation from these links.
https://github.com/qmathe/DropDownMenuKit
https://github.com/onmyway133/Dropdowns

Collection view as a sticky header in swift

I'd like to know how would you create a collection view embedded in a table view like the one you can see in Tinder app while you browse through someone's pictures.
It's obviously only a paging enabled collection but I don't know how to make it sticky at the top while still scrollable.
Thank you for your help
J.
it is embedded in a navigation controller, so the bar at the top is alway fixed. plus it is not a collection view embedded inside a tableview, that would be ridiculously redundant. It is just a CollectionView with animations.
You can use table view section header for this.
Create a UIView with UICollectionView in it.
Make this UIView as the section header of table view section. This UIView will then stick to the top for that particular section when the table is scrolled.

Space in the content of UITableView

Today I faced a weir bug in UITableView.
I have a UIViewController containing a UITableView. I also have a root viewcontroller, which will add the aforementioned UIViewController as a child.
Now when loaded, it shows a space between cells and the top border.
How can I fix that?
Try to deselect Adjust Scroll view insets option of the ComicsVC view controller.
First select ComicsVC item in the left window of your storyboard, then in the attributes inspector you will easily find this checkbox.
You have to set top position of UITableView to 0. Also you have to add constraints between UITableView and parent UIView.
This bug appears when you use translucent navigation bar.
That space shows up for grouped UITableViews, and is usually occupied by a section header. If you don't implement a section header, then the area will be blank.
If you don't have more than one section, go to the UITableView in the storyboard, show the properties, and change the style to Plain.
Hope this helps!

why header of a section of a uitableview is abnormally tall when the uitableview is embedded to a uiviewcontroller?

I would like to make a page like this (i.e. a fix segmented controller on the top, with a uitableview appending beneath it):
So, this is the way I did it: I have added a segmented controller in a uiviewcontroller, then I append a uitableview under it. Here is the diagram in the storyboard:
However, when it runs in the simulator, the header of the uitableview is abnormally tall.
I have no idea why it is like this. Am I going to a wrong direction? Thanks for any helps.
UPDATE:
This is the default setting of the uitableview. I didn't change any thing.
Select your view controller in storyboard. In the Attributes inspector, uncheck "Adjust Scroll View Insets" and uncheck "Under Top Bars".
You have placed Segment control in Tableview's header. But you had set some height to tableview section header via either xib or programmatically. That's why it leads to show this space.

Resources