viniciusmo / VMaskTextField

VMaskTextField is a library which create an input mask for iOS.
MIT License
380 stars 48 forks source link

VMaskTextField addTarget forControlEvents:UIControlEventEditingChanged #19

Open KanybekMomukeyev opened 8 years ago

KanybekMomukeyev commented 8 years ago

@viniciusmo , any ideas, why textField add target not working!

VMaskTextField *textField
[textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];

-(void)textFieldDidChange :(UITextField *)theTextField{
    NSLog( @"text changed: %@", theTextField.text);
}
felipeferri commented 7 years ago

It's a problem in [VMaskEditor shouldChangeCharactersInRange:replacementString:textField:mask]. In that method the textField.text value is set manually on code. When this happens the UIControlEventEditingChanged event is not trigered.

A solution is to paste the following line of code just next to the places where the textField is set in that method:

textField.text = returnText;
[textField sendActionsForControlEvents:UIControlEventEditingChanged];
KanybekMomukeyev commented 7 years ago

@felipeferri Good!, already fix that issue