Meaning of a UITextField Change?

How can I make a function call when the contents of a text field change?

+49
iphone uitextfield
Oct 23 '10 at 21:25
source share
4 answers
[myTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; 
+117
Oct 23 2018-10-23
source share

In fact, for the UITextField event UITextField no value with the changed value, use UIControlEventEditingChanged

+19
Jan 25 '13 at 21:30
source share

I solved the problem of changing behavior of shouldChangeChractersInRange. If you return NO, the changes will not be applied by iOS internally; instead, you have the option to change it manually and perform any actions after the changes.

 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { //Replace the string manually in the textbox textField.text = [textField.text stringByReplacingCharactersInRange:range withString:string]; //perform any logic here now that you are sure the textbox text has changed [self didChangeTextInTextField:textField]; return NO; //this make iOS not to perform any action } 
+8
Nov 11 '13 at 15:31
source share

It’s convenient for quick downloads -

 textField.addTarget(self, action: #selector(onTextChange), forControlEvents: UIControlEvents.EditingChanged) 
+1
Jul 19 '16 at 7:02
source share



All Articles