SearchController issue in UITableview - ios

In my code i added UISearchController as UITableView Header.
But if User scroll UItableview then searcher is goes up & hide.
I want to show UISearchBar stick to top.
I don't want to add it in navigation title.
I also try to add in UIViewController but it is disappear when try to search something.
Please help me to solve this.
Thank you,

Don't put the UISearchBar in the header of the UITableView. Put it outside the UITableView. It just means that your view controller will have to subclass UIViewController instead of UITableViewController.

Related

SearchBar in SplitViewController

I added SplitViewController in my app.
As per apple, Masterview must be UITableViewController.
So,I added searcher as Tableview HeaderView.
Problem
Searcher is scrolling as tableview scroll.
I want to stick searchBar at top.
Thank you for your time
Help me to solve this
uisplitviewcontroller masterview will not be always uitableviewcontroller. it can have uiviewcontroller also. check this
Does a UISplitViewController's master view always have to be a UITableView?
And additionally you cannot add sticky searchbar in uitableviewcontroller. only possible way is to creating uiviewcontroller and adding searchbar on it.
Here is how this is can be achieved. And it is actually quite simple. (The following example relies on Storyboard, but the mechanism is the same whatever you are using) :
Use UIViewController and NOT a UITableViewController
Add UITableView as the child of the parent UIView
Add a UISearchBarController also as a child view of the UIView, NOT as a child of the UITableView (UITableView and UISearchController are siblings)
Hope it will help you

Hide normal UITableView when using Search Display Controller

Both my UITableView and searchResultsTableView have a clear background color. How can I hide the normal UITableView when I'm typing into the search bar of the searchResultsTableView? I've tried hiding tableView, but it hides both tableviews. See my interface builder setup below:
I've also read the post here:
Hide UITableView when searchResultsTableView displayed
However, my Search Display Controller is not being added to the tableview, only the Search Bar is. So I'm not sure how to fix this issue.
Any help is appreciated. Thanks!
You can use the method [subView removeFromSuperview] in this case. Whenever there is a need to display the searchResultsTableView just remove the UITableView from the superview and add the searchResultsTableView in place of that by using method [self addSubview:searchResultsTableView]

Using UISearchDisplayController in a child controller

I made a tabbed controller where the tabs are on top. Underneath the tabs I have a subview which will contain a tableViewController as a child controller.
The tableViewController has a searchBar and a UISearchDisplayController. The problem is, when the search is activated, the UISearchDisplayController jutts out above the frame of the tableView and covers a bit of the tabs.
I believe this is caused by the SearchBar expanding itself on top to cover up the navigationBar.
Sorry but, why are you using a search display controller?
In this case is easier if you use just a tableView with a searchBar as well as your tab.
Then you can develop the same behaviour of the searchDisplayController.
There are developers that have never used the searchDisplayController. In general i use that just when i have a tableViewController within so just a tableView and a searchBar. But in your case, i would not use that. Take your life easier trust me ;)

Why SearchBar of Search Display Controller is not moving up in iOS7?

On my UIViewController, I took UISearchDisplayController and UITableView. The SearchBar of UISearchDisplayController is outside of UITableView because I don't want to scroll SearchBar with TableView. When started typing some text, It looks fine in iOS6 but in iOS7 SearchBar does not move up and tableView comes over it. And after search button clicked, SearchBar goes out of screen and whole screen messed up. Why is this happening?
Image:
I don't know if this problem is stil up to date, but maybe someone will have the same question. The reason of this is that You are using UIViewController instead of UITableViewController.
If it makes no difference to You, use the UITableViewController. If You have some reasons, you'll have to move searchbar programatically in searchBarShouldBeginEditing:searchBar
and searchBarShouldEndEditing:searchBar
Here's an example how: https://stackoverflow.com/a/8042790/1293285

iOS UISearchbar in UIToolbar, show search result not popover in iPad

I'm use iPad UISearchbar embed in UIToolbar, the search result will show in the UIPopover
but use iPhone, it's show in same table view
I want to search result show in the same table view, How can I do?
Thank You!
I had the issue too. What I do to fix it is instead of adding a UISearchBar in the UIToolBar via a UIBarButtomItem, I added the UISearchBar in a view (normal UIView) and added that view in the toolbar via the UIBarButtomItem. See the image below.
I don't know why, but this fix the issue.
Reload the TableView with Sorted items. Thats it.

Resources