iOS 9 Searchbar Disappears from Table Header View When Uisearchcontroller Is Active

iOS 9 searchBar disappears from table header view when UISearchController is active

It seems all of us got the same problem but they were solved in different ways. However none of the suggested answers worked for me :(. Nevertheless thank you all for your time.

I got a solution that solved my problem. It is setting Extend Edges - Under Opaque Bars of my (MyModalView: UITableViewController) to true in the Storyboard using Interface Builder.

In summary:

MyModalView: UITableViewController, in Storyboard using Interface Builder has

Extend Edges:
- Under Top Bars ticked
- Under Bottom Bars ticked
- Under Opaque Bars ticked

screenshot

UISearchController searchBar disappears on first click

Try to check the navigationBar.translucent property - it should be YES when UISearchController will present the searchBar or else will be UI bugs.

Update from @SiavA

The better solution is use the extendedLayoutIncludesOpaqueBars property of the UIViewController. If you using the opaque navigation bar just set it in the true for controller which will be show UISearchController (not for navigationController).

E.g.

- (void)viewDidLoad {
[super viewDidLoad];

self.extendedLayoutIncludesOpaqueBars = !self.navigationController.navigationBar.translucent;
}

UISearchController search bar overlap first cell when active

This is how I set up the search bar and things in viewDidLoad (copied from some of apple's examples).

It presents the found results in the same view controller as your unfiltered data is shown. It also has its search bar in the table header that is hidden until it is needed.

self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.tableView.tableHeaderView = self.searchController.searchBar;
[self.searchController.searchBar sizeToFit];

// we want to be the delegate for our filtered table so didSelectRowAtIndexPath is called for both tables
self.searchController.delegate = self;
self.searchController.dimsBackgroundDuringPresentation = NO; // default is YES
self.searchController.searchBar.delegate = self; // so we can monitor text changes + others

// Search is now just presenting a view controller. As such, the normal view controller
// presentation semantics apply. Namely, that presentation will walk up the view controller
// hierarchy until it finds the root view controller or one that defines a presentation context.
//
self.definesPresentationContext = YES; // know where you want UISearchController to be displayed

// Hides search bar initially. When the user pulls down on the list, the search bar is revealed.
[self.tableView setContentOffset:CGPointMake(0, self.searchController.searchBar.frame.size.height)];

search bar disappear after press search

try this

self.searchController.hidesNavigationBarDuringPresentation = NO
self.definesPresentationContext = NO

or use this

func willPresentSearchController(searchController: UISearchController)     {
self.navigationController.navigationBar.translucent = true
}

func willDismissSearchController(searchController: UISearchController) {
self.navigationController.navigationBar.translucent = false
}

for additional Help see this link

UITableView disappears when UISearchController is active and a new tab is selected

I got my UISearchController working with no problems on Xcode 6 beta-5 thanks to this sample project I found on GitHub.

Giving credit where credit is due, I think dempseyatgithub has done a fantastic job of making this available for everyone to use as a reference project. Thanks!

UISearchBar presented by UISearchController in table header view animates too far when active

Ok so I finally figured out a solution for myself. Though it's more than likely we have other things in our code / storyboard (that's why this is a hard question to answer), for the most part I followed Apple's tutorial on UISearchController: (https://developer.apple.com/library/ios/samplecode/TableSearch_UISearchController/Introduction/Intro.html)

Just about all my code is identical to theirs, but I couldn't get the search bar to not jump when clicking inside of it. So what I did was check "under opaque bars" for both the original table view and the search results table view in my storyboard. That got the search bar to stop jumping.

But there was one last issue, which was the fact that the first row of the results table view was hidden by the search bar. In order to fix that I added self.tableView.contentInset = UIEdgeInsetsMake(kHeightOfTableViewCells, 0, 0, 0); to the viewDidLoad method of my results table view. Voila!

UISearchBar disappears on cancel

After several hours of trying everything, I found the offending code:

func searchBarTextDidEndEditing(searchBar: UISearchBar)
{
// Dismiss the keyboard
self.resultSearchController.resignFirstResponder()

// Reload of table data
self.resultSearchController.loadView()
}

After commenting these two lines out -or better, the whole method (since I'm not doing anything else in it)- the problem sorted itself out.

NOTE: One of my coworkers implemented that method while trying different things to get the search to work as expected, and it somehow stuck...



Related Topics



Leave a reply



Submit