karim karim - 1 year ago 132
iOS Question

UITextField text change event

How can I detect any text changes in a textField? The delegate method

works for something, but it did not fulfill my need exactly. Since until it returns YES, the textField texts are not available to other observer methods.

e.g. in my code
did not get the updated text, the user has typed.

Is their any way to get something like
Java event handler.

- (BOOL)textField:(UITextField *)textField
replacementString:(NSString *)string
if (textField.tag == kTextFieldTagSubtotal
|| textField.tag == kTextFieldTagSubtotalDecimal
|| textField.tag == kTextFieldTagShipping
|| textField.tag == kTextFieldTagShippingDecimal)
[self calculateAndUpdateTextFields];


return YES;

Answer Source

From proper way do uitextfield text change call back:

I catch the characters sent to a UITextField control something like this:

// Add a "textFieldDidChange" notification method to the text field control.
[textField addTarget:self 

Then in the textFieldDidChange: method you can examine the contents of the textField, and reload your table view as needed.

You could use that and put calculateAndUpdateTextFields as your selector.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download