Skip to content

Commit

Permalink
Merge pull request #5 from gastonborba/row-value-text-did-change
Browse files Browse the repository at this point in the history
Row value text did change
  • Loading branch information
Martin Barreto committed Apr 16, 2014
2 parents 2910c11 + f0d2f8e commit addd44f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Examples/ExamplesFormViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ - (id)init


// TextFieldAndTextView
row = [XLFormRowDescriptor formRowDescriptorWithTag:kTextFieldAndTextView rowType:XLFormRowDescriptorTypeButton title:@"Text Fields Examles"];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kTextFieldAndTextView rowType:XLFormRowDescriptorTypeButton title:@"Text Fields Examples"];
row.buttonViewController = [InputsFormViewController class];
[section addFormRow:row];

Expand Down
11 changes: 10 additions & 1 deletion XLForm/XL/Cell/XLFormTextFieldCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
[self.contentView addConstraints:[self layoutConstraints]];
[self.textLabel addObserver:self forKeyPath:@"text" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:0];
[self.imageView addObserver:self forKeyPath:@"image" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:0];

[self.textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
}
return self;
}
Expand Down Expand Up @@ -249,6 +251,14 @@ - (BOOL)textFieldShouldReturn:(UITextField *)textField

- (void)textFieldDidEndEditing:(UITextField *)textField
{
[self textFieldDidChange:textField];
[self.formViewController textFieldDidEndEditing:textField];
}


#pragma mark - Helper

- (void)textFieldDidChange:(UITextField *)textField{
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeNumber]){
self.rowDescriptor.value = @([self.textField.text doubleValue]);
}
Expand All @@ -258,7 +268,6 @@ - (void)textFieldDidEndEditing:(UITextField *)textField
else{
self.rowDescriptor.value = self.textField.text;
}
[self.formViewController textFieldDidEndEditing:textField];
}

@end
5 changes: 3 additions & 2 deletions XLForm/XL/Cell/XLFormTextViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ -(void)textViewDidEndEditing:(UITextView *)textView{
[self.formViewController textViewDidEndEditing:textView];
}



-(void)textViewDidChange:(UITextView *)textView{
self.rowDescriptor.value = self.textView.text;
}

@end
4 changes: 2 additions & 2 deletions XLForm/XLForm-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<string>1.0.1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
Expand Down

0 comments on commit addd44f

Please sign in to comment.