I need to create a form that will make the screen scroll as it fills in. The idea is that the screen roll as I fill it out and thus displaying the fields below the keyboard.
I need to create a form that will make the screen scroll as it fills in. The idea is that the screen roll as I fill it out and thus displaying the fields below the keyboard.
I often use a tableViewController with static cells. When the next one becomes firstResponder and it is below the keyboard, the tableView goes up automatically.
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
if ([textField isEqual:self.seuTextField]) {
[self.proximoTextField becomeFirstResponder];
}
return YES;
}
When the user touches the return button on their keyboard, the next textField becomes the firstResponder.
It's very easy Alex. What you need is to check when the given textfield starts to be edited, and then set the contentOffset of your scrollView. As in the example below:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
if ([textField isEqual:self.myTextField]) {
[self.myScrollView setContentOffset:CGPointMake(0, 240) animated:YES];
}
return YES;
}
Remember to set the UITextField delegate before. You can do this through storyBoard or during viewDidLoad. Also remember to always return YES, otherwise the keyboard will not go up. Good Luck!