I have an IBAction
that I have connected to a UITextField
element in Interface Builder. (Firing on "value changed" event)
I also have a UISlider
that updates the TextField element automatically when it's value gets adjusted.
When I run my app, the TextField does get updated when I adjust the slider, but the "value changed" event does not fire when this happens. The value changed event also does not fire when I edit the TextField by hand as well. (Although using the Did Editing End trigger does cause it to fire).
My question is, how can I get the value changed trigger to fire for both a programmatic update of the TextField as well as when the user adjusts the value.
Don't use UIControlEventValueChanged
for UITextField
. What you want is UIControlEventEditingChanged
.
To get EditingChanged textfield event
, I suggested add selector as
[textField addTarget:self action:@selector(textChanged:) forControlEvents:UIControlEventEditingChanged];
As textfield value changed, the changed value you will get from this textChanged:
selector.
-(void)textChanged:(UITextField *)textField { NSLog(@"textfield data %@ ",textField.text); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With