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;
source share