I am calling the following function to successfully hide my search bar in viewDidLoad:

- (void)hideSearchBar {
    CGRect newBounds = self.tableView.bounds;
    newBounds.origin.y = newBounds.origin.y + _searchBar.bounds.size.height;
    self.tableView.bounds = newBounds;
}

enter image description here

but if I call the exact same function in (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar the top row of my table view becomes overlapped with the navigation bar. Why is this overlap only happening when calling the hide function from searchBarTextDidEndEditing?

enter image description here

有帮助吗?

解决方案

An answer from this question helped me realize this is somehow related to the nav bar being translucent. When I set the nav bar translucent to NO I had the issue. When I stopped making it NO, it works fine.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top