Asks the delegate if editing should stop in the specified text field.
- iOS 2.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
The text field in which editing is about to end.
YES if editing should stop or
NO if it should continue.
The text field calls this method when it is asked to resign the first responder status. This can happen when the user selects another control or when you call the text field’s
resign method. Before the focus change occurs, however, the text field calls this method and gives you a chance to prevent the change from happening.
Normally, you would return
YES from this method to allow the text field to resign the first responder status. You might return
NO, however, in cases where your delegate detects invalid contents in the text field. Returning
NO prevents the user from switching to another control until the text field contains a valid value.
Be aware that this method provides only a recommendation about whether editing should end. Even if you return
NO, UIKit might still force an end to editing. For example, text fields always resign the first responder status when they are removed from their parent view or window.
Implementation of this method by the delegate is optional. If you do not implement this method, the text field resigns the first responder status as if this method had returned