Skip to content

Instantly share code, notes, and snippets.

@taylortrimble
Created January 11, 2014 20:12
Show Gist options
  • Save taylortrimble/8376085 to your computer and use it in GitHub Desktop.
Save taylortrimble/8376085 to your computer and use it in GitHub Desktop.
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == self.lastField) {
[theTextField resignFirstResponder];
// scroll back to normal
} else if (theTextField == self.firstField) {
[self.secondField becomeFirstResponder];
// Scroll to second text field
} else if (theTextField == self.secondField) {
[self.lastField becomeFirstResponder];
// Scroll to last text field
}
return YES;
}
// Scrolling to the field
[scrollView setContentOffset:CGPointMake(0,textField.center.y-60) animated:YES];
// I'd use the textField.frame to do it though, instead of center.y-60.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment