Instance Method


Asks the delegate if the text field’s current contents should be removed.


- (BOOL)textFieldShouldClear:(UITextField *)textField;



The text field containing the text.

Return Value

YES if the text field’s contents should be cleared; otherwise, NO.


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 YES.

If you do not implement this method, the text field clears the text as if the method had returned YES.

See Also

Editing the Text Field’s Text

- textField:shouldChangeCharactersInRange:replacementString:

Asks the delegate if the specified text should be changed.

- textFieldShouldReturn:

Asks the delegate if the text field should process the pressing of the return button.