Skip to content

UITextField_textBinding

Michael edited this page Apr 22, 2016 · 3 revisions

Two-way binding that connects a source object with the text property of a text field.

Binding Source

You can specify binding constants or key paths to reference source values. Source values which are not strings will, in the absence of declared formatters, use the description of the source value object.

Binding Target

The binding targets the text property of the bound UITextField and also acts as delegate for the text field. You can still attach a UITextFieldDelegate to the text field. The binding will act as delegate proxy and forward delegate method calls to your delegate.

Binding Attributes

Inherited Attributes

Attribute Description
liveModelUpdates (Boolean) Determines whether the model value should be updated while editing, whenever the input text can be converted into a valid source value.
autoActivate (Boolean) Determines whether this text field can be automatically activated if the container control is activated.
KBActivationSequence (Boolean) Determines whether this text field participates in the keyboard activation sequence. If so, an input accessory view providing buttons to navigate to the previous or next control as well as a close button is displayed.

Formatters

Formatter binding attributes are used to convert between the source value and the text field's text. The "editing" versions of formatters are used to render the text while the field is in editing mode. If only a non-editing formatter is defined, it is used to render the text both for display and editing.

Please note that if the binding source does not accept string values, you have to configure an appropriate formatter to convert the input text into the required type.

Attribute Description
formatter, editingFormatter [[Formatter binding
numberFormatter, editingNumberFormatter [[Number formatter binding
dateFormatter, editingDateFormatter [[Date formatter binding

Replacements

Attribute Description
textForUndefinedValue Text used if the source value is nil
treatEmptyTextAsUndefined Used in conjunction with textForUndefinedValue and determines if an empty text should be considered to be undefined.