0

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.
 }
HardCode
  • 2,025
  • 4
  • 33
  • 55
  • You probably want to read up on this out here: http://stackoverflow.com/questions/1529774/objective-cuiscroller-and-uitextfields-hidden-by-keyboard-appearing-in-uiviewcon Your question is pretty much explained there with nice examples – Totumus Maximus Oct 14 '11 at 19:44
  • Thank you for pointing that out, But I need to scroll a UIScrollView! – HardCode Oct 14 '11 at 19:57

1 Answers1

0

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

Community
  • 1
  • 1
Erracity
  • 229
  • 2
  • 13