Comment puis-je faire en sorte que lorsque le contenu d'un champ de texte change, une fonction soit appelée?
Réponses
Trop de publicités?
Dmitry Shevchenko
Points
11398
Pauls
Points
251
J'ai résolu le problème en changeant le comportement de shouldChangeChractersInRange. Si vous renvoyez NON, les modifications ne seront pas appliquées par iOS en interne, mais vous aurez la possibilité de les modifier manuellement et d'effectuer toute action après les modifications.
- (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
}