Contents

textFieldShouldBeginEditing(_:)

Asks the delegate whether to begin editing in the specified text field.

Declaration

optional func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool

Parameters

  • textField:

    The text field in which editing is about to begin.

Return Value

true if editing should begin or false if it should not.

Discussion

The text field calls this method when the user performs an action that would normally initiate the editing of the text field’s text. Implement this method if you want to prevent editing from happening in some situations. For example, you could use this method to prevent the user from editing the text field’s contents more than once. Most of the time, you should return true to allow editing to proceed.

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

See Also

Managing editing