UIViewController with UITableView and UISearchBar error

I have UIViewControllers UITableViewand a UISearchBarinside. As soon as the search panel becomes the first responder, there is a small gap between the search panel and the table view.

Initial stateSearchbar becomes first responder

There is no space if it UISearchBaris a view subzone UIViewControllerinstead of being a subset UITableView.

Initial stateSearchbar becomes first responder

Obviously, one problem with this approach is that the search bar adheres to the top and does not scroll along with other cells, which is undesirable.

Any ideas?

Edit:

The first two images correspond UISearchBarto being the child of the UITableViewbreak.

UISearchBar, UIViewController, .

+4
4

UINavigationBar NO. YES, . , UISearchBar UITableView . , , , , Apple, , .

+6

, , , , uisearchbar uitableview .

0

, - , UITableView UITableViewController , , .

UISearchBar UITableView UIView, "pull-down" ( UITableViewController), "" "pull" -down " .

, , , fooobar.com/questions/1536206/..., UITableView setBackgroundView setBackgroundColor.

0

I had exactly the same problem, however, none of the above solutions worked. According to @plgrenier, the translucency of the status bar caused the problem.

One of the ways I dealt with was to use search delegates to switch transparency:

#pragma mark - Table Search Delegates
- (void) searchBarTextDidBeginEditing:(UISearchBar *)searchBar{   
      [self.navigationController.navigationBar setTranslucent:YES];
}
-(void) searchBarTextDidEndEditing:(UISearchBar *)searchBar{
  [self.navigationController.navigationBar setTranslucent:NO];
 }
0
source

All Articles