In addition to the other answers here (which essentially confirm there's no major difference, no auto-resigning of the first responder by returning YES
, etc.), I've discovered a strange occurrence completely dependent on the return value, specifically for a UITextField
with autocorrection.
Assume the following scenario:
You have a UITextField
with autocorrection enabled
You've implemented the delegate method something like this (where the text field gets resigned):
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if (textField == self.myAutocorrectingTextField) {
[self.myAutocorrectingTextField resignFirstResponder];
}
return YES;
}
You run the app, type "Cable" into the text field, then press the return key, resigning it as first responder.
The outcome when returning YES
:
- The text field's text will have been changed from "Cable" to "Cables"!
I have tested a handful of other words that respond similarly:
- "Stuff" changed to "Stuffs"
- "Ten" to "Tens"
- And, one time "Car" changed to "Carl", another time "Car" changed to "Carp"
The outcome when returning NO
:
Normal. The text field's text will not have been changed.
In Summary...
When returning YES
, the text field may autocorrect already-correct words. It does not, however, present one of those "autocorrect text bubbles", because these are legitimate words.
When returning NO
, the text field will not autocorrect already-correct words.
Note:
In both cases, incorrectly-spelled words will always be corrected. For example:
- If you were to type "Wev", an "autocorrection text bubble" should appear with the text "Web". If you hit the Return key, regardless of the delegate's return value, the text will be replaced with the correction.