I have a UITableViewController
subclass, displayed in a modal view on an iPad. The view controller has a UISearchDisplayController
subclass with a UISearchBar
included in the header view of the table.
The subclassed UISearchDisplayController
is called NoAnimationSearchDisplayController
and I have overridden the - (void)setActive:(BOOL)visible animated:(BOOL)animated
method to prevent the search bar from animating into the navigation bar when it's set to active. The method override is below...
- (void)setActive:(BOOL)visible animated:(BOOL)animated
{
if (self.active == visible) {
return;
}
[self.searchContentsController.navigationController setNavigationBarHidden:YES animated:NO];
[super setActive:visible animated:animated];
[self.searchContentsController.navigationController setNavigationBarHidden:NO animated:NO];
if (visible) {
[self.searchBar becomeFirstResponder];
} else {
[self.searchBar resignFirstResponder];
}
}
The problem I'm having, is that when I have searched, and results are displayed in my search display controller's table view, everything looks fine untill i try to scroll down the list, at this point the content within the cells appears above the search bar, as shown in the following screen:
The search bar is set to UISearchBarStyleMinimal
and transparency is enabled. Can anyone let me know how to stop this content overlapping the search bar? Ideally the content would disappear under the search bar as if it was the end of the view.
Be sure the search bar is not translucent enabled ( on storyboard/xib ) or by code. Then make the background to white or whatever color you want.
The answer was to manually change the frame of the table view provided by the
UIsearchDisplayController
in the appropriate delegate method...