Search code examples
iosscrollhideuisearchdisplaycontroller

contentInset not working with UISearchDisplayController tableView?


Using UISearchDisplayController, I am showing a UIView in bottom so causes hiding the filtered data while scrolling the table. I used contentInset property to show data in bottom.

My problem is that NSStringFromUIEdgeInsets(self.searchDisplayController.searchResultsTableView.contentInset) is showing the bottom value as 216 even if I reset the UIEdgeInsetsZero.

When I do multiple search the more data is not visible after scrolling:

enter image description here


Solution

  • if you want to set self.searchDisplayController.searchResultsTableView.contentInset, you should do in the delegate:

    - (void)searchDisplayController:(UISearchDisplayController *)controller didShowSearchResultsTableView:(UITableView *)tableView {
        controller.searchResultsTableView.contentInset = UIEdgeInsetsMake(0.0f, 0.f, 30.f, 0.f);
    }