Skip to content

Instantly share code, notes, and snippets.

@nurtugan
Last active April 18, 2020 10:53
Show Gist options
  • Save nurtugan/1ff0ebf6fa1a8a16e75dd270736d36c7 to your computer and use it in GitHub Desktop.
Save nurtugan/1ff0ebf6fa1a8a16e75dd270736d36c7 to your computer and use it in GitHub Desktop.
Switching between Text Fields on pressing return key
extension MyViewController: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
// Try to find next responder
if let nextTextField = textField.superview?.viewWithTag(textField.tag + 1) as? UITextField {
nextTextField.becomeFirstResponder()
} else {
// Not found, so remove keyboard
textField.resignFirstResponder()
}
// Do not add a line break
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment