I have an xCode project that contains a tableview with a “Search Bar and Search Display Controller” to allow the user to refine the list of displayed items. In general, the
I googled all over internet and couldn't find a solution. so i changed the UItableview behaviour.
instead of [searchBar becomeFirstResponder]; I scroll down the tableview.
- (IBAction)goToSearch:(id)sender {
scroll down to show the table.
// CGRect newBounds = self.TableView.bounds;
// newBounds.origin.y =0;
//
// self.TableView.bounds = newBounds;
//[searchBar becomeFirstResponder];
CGPoint contentOffset=self.TableView.contentOffset;
contentOffset.y=0;
[self.TableView setContentOffset:contentOffset animated:YES];
}
in my ViewDidload:
// CGRect newBounds = self.TableView.bounds;
// newBounds.origin.y = newBounds.origin.y + searchBar.bounds.size.height;
// self.TableView.bounds = newBounds;
CGPoint contentOffset=self.TableView.contentOffset;
contentOffset.y=self.TableView.bounds.origin.y + searchBar.bounds.size.height;
self.TableView.contentOffset=contentOffset;
If found for some reasons, in iOS 7 , change table view bounds cause search bar to disappear. Hope that helps.