The slide is formed when the keyboard appears.

Hi, I am using a form to enter data, some text fields are at the bottom of the form. when I click on the text fields for recording, the keyboard appears and hides the fields that execute it. if I make the text field the first responder, it hides the keyboard, but by doing this I cannot do this. I want to know how it is possible that when the keyboard appears, the whole form should move up as my last field appears on the key bar in advance thanks

+4
source share
3 answers

Add all your scroll view and set the scroll delegate and text box, then use that delegate and method -

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ [self scrollViewToCenterOfScreen:textField]; return YES; } -(BOOL) textFieldShouldReturn:(UITextField *)textField{ if ([textField isEqual:txtField1]) { [txtField2 becomeFirstResponder]; } else if ([textField isEqual:txtField2]) { [txtField3 becomeFirstResponder]; } else { [textField resignFirstResponder]; [scrollView setContentOffset:CGPointMake(0, 0) animated:YES]; } return YES; } - (void)scrollViewToCenterOfScreen:(UIView *)theView { CGFloat viewCenterY = theView.center.y; CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame]; CGFloat availableHeight = applicationFrame.size.height - 200; // Remove area covered by keyboard CGFloat y = viewCenterY - availableHeight / 2.0; if (y < 0) { y = 0; } [scrollView setContentOffset:CGPointMake(0, y) animated:YES]; } 
+6
source

There are several strategies you can use for this: most of them include wrapping your view in a UIScrollView and scrolling to the corresponding control as it receives focus. You can find Apple's documentation on how to do this here: http://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html

+1
source

All Articles