Why am I getting a gap between my UISearchBar and my UITableView cell header when I touch the UISearchBar on iOS7?

These two photos should explain this. The first one shows mine UITableViewas a rule. The second one shows when I touch UISearchBarand it focuses. Why is there a gap between the cell title and the search bar? Does anyone know how to fix this?

iOS 7 when this happens, by the way. I already have this code:

- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (tableView == self.searchDisplayController.searchResultsTableView)
    {
        return 0;
    }
    else
    {
        return 23;
    }
}

enter image description here

enter image description here

+3
source share
2 answers

I fixed this problem in my code by deleting the following two lines of code.

self.viewController.edgesForExtendedLayout = UIRectEdgeNone; self.navigationBar.translucent = NO;

Hope this leads you in the right direction.

+3
source

iOS 7 UITableView. UITableView. ( UITableViewDelegate).

- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 1;
}
-1

All Articles