Clicking in a textfield makes the keyboard appear. How do I hide it when the user presses the return key?
Set delegate of UITextField in view controller, field.delegate = self, and then:
extension ViewController: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
// don't force `endEditing` if you want to be asked for resigning
// also return real flow value, not strict, like: true / false
return textField.endEditing(false)
}
}