Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextField "value changed" not firing when field is updated

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.

like image 525
Andrew Lauer Barinov Avatar asked Nov 22 '11 09:11

Andrew Lauer Barinov


2 Answers

Don't use UIControlEventValueChanged for UITextField. What you want is UIControlEventEditingChanged.

like image 174
Mark Adams Avatar answered Sep 21 '22 17:09

Mark Adams


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); } 
like image 24
Kirti Nikam Avatar answered Sep 21 '22 17:09

Kirti Nikam