I have multiple text fields on a view controller, and have implemented the textFieldShouldReturn function so that when I hit return, it goes to the next text field. However, right now the screen stays the same, so the active text field is covered up by the keyboard.
How can I make it so that the screen scrolls down and I can see the active text field?
Relevant code:
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
let nextTextFieldTag = textField.tag + 1
let nextTextField = textField.superview?.viewWithTag(nextTextFieldTag)
if nextTextField != nil {
nextTextField?.becomeFirstResponder()
} else {
textField.resignFirstResponder()
}
return false
}