nicklockwood / FXForms

[DEPRECATED]
Other
2.93k stars 339 forks source link

FXFormTextFieldCell delegate is nil #410

Open ldantona opened 9 years ago

ldantona commented 9 years ago

Hi all,

I've subclassed FXFormTextFieldCell in order to create a custom .xib file.

Here's the implementation:

@implementation FormTextFieldCell

-(void)setUp{
    [super setUp];

}

- (void)update {
    [super update];

    self.txtField.returnKeyType = UIReturnKeyDefault;
}

- (UITextField *)textField {
    return self.txtField;
}

- (UILabel *)textLabel {
    return self.lblField;
}

@end

When the execution enters setUp and reaches line 2827 of FXForms.m:

self.textField.delegate = self;

self.textField returns nil and therefore the delegate is not set. This is strange as the textField getter is defined as showed above. As a workaround I've added self.textField.delegate = self; at the beginning of the update method in FXForms.m:

- (void)update
{
    self.textField.delegate = self; // <--
    self.textLabel.text = self.field.title;
    self.textField.placeholder = [self.field.placeholder fieldDescription];
    self.textField.text = [self.field fieldDescription];
    ...

Has anyone experienced any similar behavior?

Thanks, DAN