I’m doing a form in an iPhone application. I’m setting the next field on the return of the keyboard. Everything works fine but if the text field is hidden under the keyboard, it’s not scrolling on top of the keyboard dynamically! How can I do this?
Here is my code
It basically set to the next tag (next fileld)
-(BOOL)textFieldShouldReturn:(UITextField*)textField;
{
NSInteger nextTag = textField.tag + 1;
// Try to find next responder
UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];
if (nextResponder) {
// Found next responder, so set it.
[nextResponder becomeFirstResponder];
} else {
// Not found, so remove keyboard.
[textField resignFirstResponder];
}
return NO; // We do not want UITextField to insert line-breaks.
}
Check out this question for sample code:
How programmatically move a UIScrollView to focus in a control above keyboard?
It sounds like what you want to use is the scrollRectToVisible:animated: method.
Here’s documentation for UIScrollView to read more about the above method:
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html