I have a problem with UITableView, particularly with scrollToRowAtIndexPath. Here we set a section-header-height and row-height respectively. Later on, when a keyboard is shown, I’ve resize the tableview and scroll to current involved cell using scrollToRowAtIndexPath. The problem is, after trying 3 different type of positioning, only UITableViewScrollPositionTop is positioned correctly while UITableViewScrollPositionMiddle and UITableViewScrollPositionBottom is misplaced. Here’re the screenshots:


Like the images shown, the top positioning put the row at the top, while middle and bottom positioning is put at around 1 row up of the middle row (for both of them). This only happening in this view (it works fine on other view).
The tableview has fixed margin and flexible width/height (denoted by all marks are bright red in the IB).
I’ve try to check the origin point of the tableview, it stated 0,0. When I move the origin.y a few pixel, the tableview does move down that amount so this wasn’t caused by tableview origin point.
I’ve using this code to get the indexPath before resizing (note that this works fine on other views):
NSIndexPath *indexPath = [tblView indexPathForRowAtPoint:self.frame.origin];
//resize the tableview
[tblView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
Any idea on why is this position shifting is happening?
Thanks in advance.
OK. Now I know the cause of this problem and I think I have to share it here since I’m asking here in the first place.
It’s because the previous developer set the Content Insets Bottom of Scroll View Size of UITableView to 100 in the xib file (the default value should be 0 I think). This picture show where I found this property:
