UITableView won't scroll with a UISearchBar - uitableview

This should be a fairly general question, but I have a view in which I placed a UITableView and implemented it properly. It works well and it scrolls. But I want to add a UISearchBar attached to it so that it will scroll along with the table. But when I add the search bar onto the tableview it shows up, but the tableview will not scroll anymore. I don't actually need any input into the search bar, and I disabled user interaction. Is there any way to add the search bar (no need to implement it) and have it scroll?
(I will rate up anyone who answers!)
Thanks

The UISearchBar should be the UITableView's header view.

Had similar issue even when IB had the correct bouncing properties enabled.
In your viewDidLoad, set self.tableView.alwaysBounceVertical = YES;.

Related

UIView with container view not scrolling properly when keyboard appears

I have an issue dealing with a UIContainerView inside a UIView. When I try to show the keyboard to edit one of the fields I would expect the whole UIView (with the UIContainerView inside it) to scroll up and out of the way of the keyboard.
Here is what I see at the moment. Does anybody have any suggestions on how to resolve this issue?
The automatic scrolling for input only happens in things like UITableView. For this one, refer to the Apple guide of managing keyboards.
Essentially, you want to manually scroll up the view when the keyboards appear and put it back when the keyboard is hidden.
Edit: I just realised that you have a
UITableViewController. My guess would be because it's on fullscreen, the table view doesn't have enough room to scroll. In this case, you would need to put the all the views inside a scroll view and follow the guide above.

Swift; is scrollView with tableView feasible?

I've have been trying for a while now, to implement a specific behavior in my app. On the initial view of my app, there must be a logo(imageView), a label and a textField. It should be possible to scroll down from the initial view, to a tableView. while the user scrolls down, the label in moved up in the window, to form a search field for the tableView. Then the scrollView should lock to the part with the tableView, and it should only be possible to scroll back up, if dragging elsewhere than the tableView.
What is best practice for doing as described?
The image show (only for illustration, i havn't been using story board when trying to implement it) an overview of the problem:
The way I've tried to do this so far, is by embedding the tableView in a scrollView (as seen on image), enabling paging on the scrollView, and than disabling scrolling on the scrollView, when the buttom part has been reached. I've added a gesture reconizer on the part with of the screen with the textField.
These two posts (Scrollview with embedded tableview and Use Pan Recognizer to Control ScrollView) descripe i further detail what i've tried so far.
But the question is more to, is there an alternate solution for making behaviour descriped above?
Maybe interactive animated transitioning between view controllers somehow?
YES there are! Implement a table view with a header view. And remove the scroll view.
self.tableView.tableHeaderView = topView
where topView will be the view wish as the UIImage, the label and textField

How to make UIView hides in UITableView as UISearchBar

So... We have UITableView. If we add UISearchBar to the top of UITableView than we will have search bar, that can be hidden by scrolling our table (even if table is empty) and it's working out of box
I'd like to add UIView instead of Search bar and have the same behavior. The questions is how it's working? What method/property does that?
In your viewWillAppear: method add just self.tableView.contentOffset = CGPointMake(0, myView.frame.size.height);
this is not an easy subject. You should create a UIScrollView and inside it your view (at the top) and your tableView. But a tableView is another ScrollView (ScrollView is the father than tableView), and you need switch between them in order one receive the drag event or the other. In all WWDC Videos, there is a video about scrollView, in the last you can find one than explain how to do this.

Hide Nav Bar and move Table View Section Headers

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! :)

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];

Resources