I have doubts when i implement the delegate method textFieldShouldReturn
of UITextField
, I don't know what's difference between the return value.
I have tried return false
and return true
in it, but I didn't find the difference between them, and my custom delegate methods are all executed, the program seems to work fine.
Here is my code:
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
let legalInput = tagTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
if !legalInput.isEmpty {
if isUpdate {
if tag!.tagName != legalInput {
delegate?.didUpdateTagName(tagName: legalInput)
}
} else {
delegate?.didAddTag(tagName: legalInput, themeId: themeId)
}
}
navigationController?.popViewController(animated: true)
// return false
return true
}