iOS 7 UISearchDisplayController search bar disappears

前端 未结 4 632
别那么骄傲
别那么骄傲 2020-12-29 13:50

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 kee

4条回答
  •  春和景丽
    2020-12-29 14:19

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

提交回复
热议问题