I am using a subclassed tableView made by someone else, and it comes with a method loadObjectsthat causes the tableView to overflow its cells, however it does not report that the table view returns to the beginning after reloading. I tried to implement this function with:
- (void)loadObjects{
[super loadObjects];
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
However, as soon as it is called loadObjects(when the table view wants to load first), I get the following exception:
*** Terminating app due to uncaught exception 'NSRangeException', reason:
'-[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:]:
row (0) beyond bounds (0) for section (0).'
I passed a line that I wrote that scrolls the view of the table to the top to another user method, which is called whenever I click the button, and everything works fine, so there is a problem with my rewriting loadObjects. Does anyone understand the exception that was thrown?
source
share