Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 UISearchDisplayController search bar disappears

I was recently updating my app and came across this issue. When i start typing in the search bar the search bar disappears and i can only see the table view. I can still keep on typing and the table view gets updated but i cannot see the search bar. Same settings works fine on iOS < 7

Any idea why this is happening ?

Step 1Step 2Step 3

like image 668
Tarang Avatar asked Sep 24 '13 18:09

Tarang


1 Answers

A little late, but I've encounter the same problem just recently. I wanted the search bar to be visible and active through all of the search, so the dimmed view, which overlaid it, was a big problem. For me the only thing that worked was changing the frame of the dimmed view (apparently it's not the same as changing the frame of searchResultsTableView). I've managed to do that with the following code:

-(void)setCorrectFrames
{
    // Here we set the frame to avoid overlay
    CGRect searchDisplayerFrame = self.searchDisplayController.searchResultsTableView.superview.frame;
    searchDisplayerFrame.origin.y = CGRectGetMaxY(self.searchDisplayController.searchBar.frame);
    searchDisplayerFrame.size.height -= searchDisplayerFrame.origin.y;
    self.searchDisplayController.searchResultsTableView.superview.frame = searchDisplayerFrame;    
}

-(void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
    [self setCorrectFrames];
}

-(void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller
{
    [self setCorrectFrames];
}
like image 148
Tihi Avatar answered Oct 07 '22 03:10

Tihi