I have a view controller for a view with six UITextFields. Whenever the user selects a text field, I need to scroll things upwards. So the text fields all set the view controller as their respective delegates. When the delegate method fires, it then calls a scroll method to scroll things up (if the keyboard is appearing) or down (if it is disappearing). The scroll method looks like this:
- (void) scroll: (CGFloat) distanceUp {
[UIView beginAnimations:@"Scroll" context:NULL];
//move some stuff up by distanceUp, or down if distanceUp is negative.
[UIView commitAnimations];
}
If the user selects a text field, enters a value, then hits the DONE button on the keyboard, this works fine.
The problem comes when the user switches directly from one textfield directly to another. In that case, what happens is that the view jumps downwards, then scrolls back up. Obviously I would prefer that it just remain in place. How do I make it do that?