nicklockwood / FXForms

[DEPRECATED]
Other
2.93k stars 339 forks source link

Text input value changing events #442

Closed mrsnow-git closed 8 years ago

mrsnow-git commented 8 years ago

Is there options to get notifications about text field value changing ? to make something if get some value, for example.

wxhui commented 8 years ago

In my case,i use a custom textFiledCell and implement the textfield delegate methods.

mrsnow-git commented 8 years ago

I solve it for y project in other way:

on controller creation after creating the form I add

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldTextDidChange:) name:UITextFieldTextDidChangeNotification object:nil];

and have

- (void)textFieldTextDidChange:(NSNotification *)notification
{
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self updateFormDataState];
    });
}

I've added dispatch_after to be able to get in updateFormDataState the updated values for all fields interested for me.

so now I can control some buttons states corresponding to fields text, for example disable Save button if some field are empty...