Hide Nav Bar and move Table View Section Headers - ios

I am currently using the https://github.com/telly/TLYShyNavBar class to hide my nav bar when scrolling, it works great and is extremely simple to use. But I am using it on a table view controller so when I scroll up my section headers don't move and it looks like this.
How can I move up the section headers to the top of the screen. Or use a different way to move the nav bar when scrolling.
Thanks for the help in advance.

You could use the first TableViewCell as a custom navigation bar by adding buttons to the contentview contained in the TableViewCell. It would scroll up like any other TableViewCell. TableViewCells are mostly just a wrapper for a UIView. You can modify that UIView like any other UIView. Every TableViewCell has a property called contentview which is the main UIView in the Cell.
As an example, you could add a button to the first cell that sends the following message
[self.navigationController popViewControllerAnimated:YES];
You could call that button "Back"
https://developer.apple.com/library/IOs/documentation/UIKit/Reference/UITableViewCell_Class/index.html#//apple_ref/occ/instp/UITableViewCell/contentView

I found a solution for this!
The problem is that, the section header stays at the top value of the contentInset. Even though the navigation bar is out of view and the tableView is visible below, the contentInset will remain same.
You would have to modify the library to increase or decrease the top value of the contentInset, according to the scrolling offset. Try this out and you may post it as a pull request in github.
Hope this helps! :)

Related

iOS 11 navigationbar scroll

so, the setup looks like this:
I want to have one navigationbar and three collectionViews. I want to be able to horizontally scroll through the collectionviews and on vertical scroll the navigationBar large title animation should trigger as well.
What I have tried:
My first try was to create one horizontally.scrolling collectionView with cells having the size of the whole view and in each cell there would be another collectionView that would scroll vertically. Now, that worked great for my purpose but the large title stayed the same size - which, as I understand, is because it does not receive any vertical scroll events since my collectionViews for vertical scrolling are embedded in main collectionView.
It looked like this: https://giphy.com/gifs/50hYRx71XSdYA/html5
Then I tried a different approach. I created pageViewController and two viewControllers both with one vertically-scrolling collectionView. And ... it did not work either. This time if there was pageCurl animation, the navigation title DID animate - but I do not want a pageCurl animation, you can see that here: https://giphy.com/gifs/jFmOpEtUOyxtC/html5
Changing the animation to .scroll just disabled the title animation: https://giphy.com/gifs/l0IsGVhKKb0lzomqc/html5
I can not find a way to do this, do any of you have any idea?
Thanks!
Unfortunately the new self-collapsing navigation bar is using some private Apple-magic in the background to hook into the top-level scroll view of the view controller, therefore you cannot use this mechanism the way you've described.

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!

How to add buttons and search bar into header at top of UITableViewController?

I have a search bar and some buttons in a view in my UITableViewController, but I don't know how to make that view the header? I've attached the referencing outlet to the UITableController. But currently the search bar and buttons scroll up and down with the tableview, but I want them to be the header so they stay fixed.
Here's a screen shot of what I currently have...
ok I ctrl/dragged from the view to my ViewController and created a IBOutlet, as you can see in this next image, and I added in the line to set it to be the header but it seems to give an error??
The easiest solution would be to move that view containing the search bar and buttons to being a subview of the view controller's view instead of inside the table view. Then apply your constraints so that it is pinned to the top and the table view is constrained to the bottom of the view.
If the list of elements you are displaying do not have more than one section, then you could implement the tableView:viewForHeaderInSection: delegate method. Create the headerview containing the searchbar in storyboard and return the instance. It will be always on top of the list.
Apple Documentaion

How to make pressing the status bar scroll to the top of any UITableView?

I have a UITableView within my UIViewController.
I want the table to scroll to the top when the status bar is pressed. i've tried self.tableView.scrollsToTop = YES but it does not scroll the table to the top.
Any idea on how to make this work?
Looking at the documentation for UIScrollView, scrolls to top, there is a special consideration: "on iPhone, the scroll-to-top gesture has no effect if there is more than one scroll view on-screen that has scrollsToTop set to yes."
This could be part of the issue, without seeing your actual code.
Another technique you might employ since it sounds like a uitableview nested inside a view controller, is to call scrollToRowAtIndexPath:atScrollPosition:animated:
So, detect when status bar is pressed, then call [YourTable scrollToRowAtIndexPath:probably0 atScrollPosition: UITableViewScrollPositionTop animated:YES/NO];

UISegementController in top of UITableView

I would like to add a UISegmentController in the top of my UITableViewController, just like in the AppStore.
I have tried googleing this but either I am search for the wrong things, or too view have written about this.
How can I do this, keeping it in the top with a different design than the UINavigationBar.
For style add segmentCont.segmentedControlStyle=7; which is same as the picture style.
It may not be a UITableViewController. It might be just a UIViewController with a segment control at the top of the XIB and a tableview placed underneath the segment control. That way, you could scroll the table view without scrolling the segment control.
I believe that is a custom header cell for the tableview. You should start by created a custom header with your segmented control inside that.
I think that's a ToolBar with UISegmentedControl or just UISegmentedControl and UITableView under it. You can place them (UISegmentedControl + UITableViewController) on UIScrollView and disable scroll for UITableView. You should make appropriate contentSize for your scrollview.

Resources