Skip to content

Instantly share code, notes, and snippets.

@nwalter08
Created May 16, 2013 20:58
Show Gist options
  • Save nwalter08/5595045 to your computer and use it in GitHub Desktop.
Save nwalter08/5595045 to your computer and use it in GitHub Desktop.
// Calculate the size of the tableView if it were to be dispalyed
[self.tableView layoutIfNeeded];
// If the conent of the tableView is too small to scroll past the search bar...
if (self.tableView.contentSize.height < self.tableView.frame.size.height) {
// Add the difference and the height of the serachBarView to the bottom of the contentSize
CGFloat diff = self.tableView.frame.size.height - self.tableView.contentSize.height;
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, (diff + 44), 0);
}
// Scroll to the first section and the first row of the tableView
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment