So the goal is to do the insert and position the content in such a way that all of the inserted rows are visible. This is doable as long as the inserted rows are shorter than the table itself.
It seems that the scroll animation and the insertion are interfering with one another. To fix, let's do the scroll first, because the docs provide a clear hook for when that animation finishes, namely, the delegate method - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
The solution would go something like this:
// about to insert cells at arCells index paths
// first scroll so that the top is visible
NSIndexPath *firstNewIndexPath = [arCells objectAtIndex:0];
NSInteger previousRow = MAX(firstNewIndexPath.row-1, 0);
NSIndexPath *previousIndexPath = [NSIndexPath indexPathForRow:previousRow inSection:firstNewIndexPath.section];
// if the new rows are at the bottom, adjust the content inset so the scrolling can happen
if (firstNewIndexPath.row > [self.tableView numberOfRowsInSection:0) {
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, self.tableView.frame.size.height - 80, 0); // 80 is just to illustrate, get a better row height from the table
}
[self.tableView scrollToRowAtIndexPath:previousIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
// there may be a better way to setup that scroll, not sure, but that should work.
Now we have a hook to know that the animation finished. We can safely do the insert...
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
// hopefully you have those arCells in an instance variable already, otherwise
// i think you'll need to create one to save state in between the two animations
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:arCells withRowAnimation:UITableViewRowAnimationLeft];
[self.tableView endUpdates];
// restore the content inset
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
}
A couple other SO articles like this one deal with getting a hook to tell us the row animation is done. That might be better because then we have a better idea where to scroll to (as your questions suggests, to the bottom of the newly inserted rows). But none of these seem certain to let us know that the animation is done.