textFieldShouldClear(_:)
Asks the delegate whether to remove the text field’s current contents.
Declaration
optional func textFieldShouldClear(_ textField: UITextField) -> BoolParameters
- textField:
The text field containing the text.
Return Value
true if the text field’s contents should be cleared; otherwise, false.
Discussion
The text field calls this method in response to the user pressing the built-in clear button. (This button is not shown by default but can be enabled by changing the value in the clearButtonMode property of the text field.) This method is also called when editing begins and the clearsOnBeginEditing property of the text field is set to true.
If you do not implement this method, the text field clears the text as if the method had returned true.