I am using a scroll view that contains a couple of text field. When the text field "begins editing", I perform 3 operations:
I change the scroll view content inset (so that the whole view becomes apparent above the keyboard). I only do that if it's not fixed already to this content inset.
I also change the scroll indicator inset to match the one in 1.
Finally, I change the scroll view content offset to some specific value.
However, a strange thing happens. Once I tap the text field, the scroll view animates to a content offset larger than the specific value, then immediately back to that specific value.
I suspected that both step 1 and 2 are the reasons for that so I excluded them and everything works just fine. However, this left me with part of the scroll view hidden below the keyboard.
EDIT: Here is the code I use (called when the text field starts editing):
UIScrollView *scrollView = (UIScrollView *) self.view;
if (scrollView.contentInset.bottom != C_SCROLL_VIEW_CONTENT_INSET_BOTTOM) {
[scrollView setContentInset:UIEdgeInsetsMake(C_ORIGIN_ZERO,
C_ORIGIN_ZERO,
C_SCROLL_VIEW_CONTENT_INSET_BOTTOM,
C_ORIGIN_ZERO)];
[scrollView setScrollIndicatorInsets:UIEdgeInsetsMake(C_ORIGIN_ZERO,
C_ORIGIN_ZERO,
C_SCROLL_VIEW_CONTENT_INSET_BOTTOM,
C_ORIGIN_ZERO)];
}
if (textField.tag == C_TAG_BUTTON) {
[scrollView setContentOffset:CGPointMake(C_ORIGIN_ZERO, C_ORIGIN_SHIFT_SCROLL_VIEW_FOR_CURRENT_Y)
animated:YES];
return;
}