Hide normal UITableView when using Search Display Controller - ios

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]

Related

SearchController issue in UITableview

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.

IOS Customizing UISearchBar and Search Display

Hey I have been trying to customize a UISearch bar with display controller and have run into some issues customizing certain aspects of the search and display controllers. I'm using storyboard and am developing with the most recent version of IOS 6.
The first issue is eliminating the dark grey gradient overlay that appears when you first click on the search text view. I have tried to use the searchDisplayController:willShowSearchResultsTableView: delegate but am unable to either find the view that is being used as the gradient overlay or a property to disable it. How do I remove this view?
The second is I am having an issue with the initial animation that is triggered when the search view is clicked. The animation is supposed to expand the search bar over the UINavigationBar to allow for a larger space to view the results. This doesn't happen and the search bar stays below the UINavigationBar and the animation doesn't properly show. I have tried setting the displaysSearchBarInNavigationBar and navigationItem properties but couldn't find any way to access or set them. Could this be an issue with the fact that I'm using autolayout in my story board? I have noticed that many issues relating to the UISearchBar animations are due to autolayout being used in the .xib or storyboard file. How can I make it correctly over the navigation bar?
The third issue I am having is with over ridding the searchBarTextDidBeginEditing:(UISearchBar *)searchBar delegate method. I have subclassed the UISearchBar to allow for complete customization. Is there a way to provide a default definition for the searchBarTextDidBeginEditing: delegate method inside my custom UISearchBar subclass. I want to provide a specific style of text in the UITextView when the user clicks on the search bar and don't want to have to redefine this method in every view controller that uses the search bar. Is this possible?
Thanks for the help in solving these issues.

Create a search bar like in the iOS 7 Contacts app

I have an application where I have a UITableView with sections which are scrollable on the side through sectionIndexTitlesForTableView:.
In the tableHeaderView of the UITableView I want to add a UISearchBar, which I want to behave like the one Apple is using in their new Contacts app in iOS7. But I can't seem to get it to work.
The search bar is not 100% the width of the screen, but instead has its right side against the section index.
My questions are:
How do I get the search bar's width to 100% when it's the tableHeaderView of a UITableView that has a visible section index?
How can I create a transition like in the Contacts app of iOS 7 where the navigation bar hides and the search bar's grey background extends to the status bar?
I have tried several things already, including adding the search bar in the navigation bar, and using UISearchBarController, but I can't find good documentation on the Apple website on how to create this. Also, the transition guide from iOS6 to iOS7 has been no good help for me.
Here are two pictures that illustrate my problem:
Two main differences to the way Apple do their app, which will solve your problems.
First, their UISearchBar isn't the headerView for the tableView. It's a separate view above the table. You'll need to change your UITableViewController to a UIViewController that has a UITableView positioned just below your UISearchBar.
Second, their UISearchBar has an associated Search Display Controller. Assuming you're using a storyboard file, this comes bundled together for you - just add the UISearchBar with the Search Display Controller. This will handle all of the transitioning to underneath the status bar for you.
Two things:
1) Set tableView's sectionIndexBackgroundColor to [UIColor clearColor].
2) Implement 'viewDidLayoutSubviews' method to fix frame for UISearchBar
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
CGRect barFrame = self.searchBar.frame;
barFrame.size.width = self.view.bounds.size.width;
self.searchBar.frame = barFrame;
}

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.

Hide/show search bar with pressing a button

I have a tableview with a search bar. All is working fine but now I want a button to hide/show the search bar. This functionality is what my question is about.
Now I have created a bar below the screen where I have created a button for this. In code, there is a void function which can be filled with the code I am looking for. Just to give you an impression of how the code looks like. Right now it is empty.
I've done some research and I came up with bringSubViewToFront and sendSubViewToBack, HeadsUpUI sample app. The idea I had was that I could show the search bar by bringing it to front, put OVER the table view layer, while setting the tableview 44 pixels lower with content offset or so.
Likewise, sending the search bar layer to back, BEHIND the table view to hide it. So in the void function I tried something with [parentview sendSubViewToBack:child view] but to no effect. So my question is: how do I hide or show my search bar while having a table view and a navigation bar and a bar below with the button to do so?
Kind Regards,
John
Use like -
childview.hidden = YES;
EDIT 1-
childview.hidden = YES;
[parentview sendSubViewToBack:childview];
[tableView reloadData];
Hope it work for you.
You can use IBOutlate to your searchBar and then use this outlate to show or hide the search bar
Also don't forget to connect it with your searchBar in xib

Resources