I have a UITableView with a cell that is dynamically sized to fit a UITextView inside it. Whenever a key is typed, the cell checks to see if the calculated height has increased, as with a newline, so it can tell the table the the cell's height needs to be recalculated. I do that with this code.
- (void) createNoteCellViewDidUpdate: (CreateNoteCell*) cell {
CGFloat newHeight = [self tableView:self.tableView heightForRowAtIndexPath:CreateNoteCellIndexPath];
if (newHeight != CGRectGetHeight(cell.contentView.frame)) {
[self.tableView beginUpdates];
[self.tableView endUpdates]; // <- HERE IS WHERE THE CONTENT OFFSET CHANGES
}
}
The resize and table bounds are as expected. But instead of just animating the change in height, it also scrolls to the top. This can be seen here, when pressing the return key.
By Key Value Observing, I've found out that the scroll view contentOffset is being set when the scroll view's contentSize changes. And that the contentSize changes many times when the endUpdates method is called. When it changes it goes from a normal height, to a rather large height, then back to a normal height. I wonder if it's going to top because of that. I don't know where to go from here.