2 Commits

Author SHA1 Message Date
pastorin 00e512a37b Merge branch 'master' into addSections 2015-04-21 09:41:51 -03:00
pastorin f4129a367b Example - Add dynamic sections with multiple rows 2015-04-21 09:38:03 -03:00
4 changed files with 51 additions and 1 deletions
@@ -71,6 +71,18 @@
row.selectorOptions = @[@"Option 1", @"Option 2", @"Option 3"];
section.multivaluedRowTemplate = [row copy];
[section addFormRow:row];
// Add Section Button
section = [XLFormSectionDescriptor formSection];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"AddSectionButton" rowType:XLFormRowDescriptorTypeButton title:@"Add Section"];
row.action.formSelector = @selector(didTouchAddSectionButton:);
[row.cellConfigAtConfigure setObject:[UIColor clearColor] forKey:@"backgroundColor"];
[row.cellConfig setObject:[UIColor grayColor] forKey:@"textLabel.color"];
[row.cellConfig setObject:[UIFont fontWithName:@"Helvetica" size:17] forKey:@"textLabel.font"];
[section addFormRow:row];
return [super initWithForm:form];
}
@@ -90,6 +102,25 @@
}
-(void)didTouchAddSectionButton:(XLFormRowDescriptor *)sender
{
// Create a new section
XLFormSectionDescriptor * newSection = [XLFormSectionDescriptor formSectionWithTitle:[NSString stringWithFormat:@"Section created at %@", [NSDateFormatter localizedStringFromDate:[NSDate new] dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterShortStyle]]];
newSection.multivaluedTag = [NSString stringWithFormat:@"multivaluedPushSelector_%@", @(self.form.formSections.count-1)];
// Add rows to the new section
XLFormRowDescriptor * newRow = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeSelectorPush title:@"Language"];
newRow.selectorOptions = @[@"Option 1", @"Option 2", @"Option 3"];
[newSection addFormRow:newRow];
newRow = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeSelectorPush title:@"Level"];
newRow.selectorOptions = @[@"Option A", @"Option B", @"Option C"];
[newSection addFormRow:newRow];
// Add new section
[self.form addFormSection:newSection beforeSection:sender.sectionDescriptor];
[self deselectFormRow:sender];
}
#pragma mark - UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
@@ -116,6 +147,7 @@
}
}
@end
+1 -1
View File
@@ -900,9 +900,9 @@ Version 3.0.0 (master)
* `hidden` property added to `XLFormSectionDescriptor`. `@YES` `@NO` or a `NSPredicate` can be used to hide the section.
* Added `XLFormRowDescriptorTypeCountDownTimerInline` and `XLFormRowDescriptorTypeCountDownTimer` row type with an example.
* Deleted `dateFormatter` property and added support to use the `NSValueTransformer` to convert the selected object to a NSString in the XLFormDateCell class.
* Added `XLFormRowDescriptorTypeCountDownTimerInline` and `XLFormRowDescriptorTypeCountDownTimer` row type with an example.
* Deleted `dateFormatter` property and added support to use the `NSValueTransformer` to convert the selected object to a NSString in the XLFormDateCell class.
* Added example in the ```Multivalued Sections examples``` of how to add dynamic sections with multiple rows.
Version 2.2.0
+1
View File
@@ -64,6 +64,7 @@ typedef NS_OPTIONS(NSUInteger, XLFormRowNavigationOptions) {
-(void)addFormSection:(XLFormSectionDescriptor *)formSection;
-(void)addFormSection:(XLFormSectionDescriptor *)formSection atIndex:(NSUInteger)index;
-(void)addFormSection:(XLFormSectionDescriptor *)formSection beforeSection:(XLFormSectionDescriptor *)beforeSection;
-(void)addFormSection:(XLFormSectionDescriptor *)formSection afterSection:(XLFormSectionDescriptor *)afterSection;
-(void)addFormRow:(XLFormRowDescriptor *)formRow beforeRow:(XLFormRowDescriptor *)afterRow;
-(void)addFormRow:(XLFormRowDescriptor *)formRow beforeRowTag:(NSString *)afterRowTag;
+17
View File
@@ -126,6 +126,23 @@ NSString * const XLValidationStatusErrorKey = @"XLValidationStatusErrorKey";
formSection.hidden = formSection.hidden;
}
-(void)addFormSection:(XLFormSectionDescriptor *)formSection beforeSection:(XLFormSectionDescriptor *)afterSection
{
NSUInteger sectionIndex;
NSUInteger allSectionIndex;
if ((sectionIndex = [self.allSections indexOfObject:formSection]) == NSNotFound){
allSectionIndex = [self.allSections indexOfObject:afterSection];
if (allSectionIndex != NSNotFound) {
[self insertObject:formSection inAllSectionsAtIndex:allSectionIndex];
}
else { //case when afterSection does not exist. Just insert at the end.
[self addFormSection:formSection];
return;
}
}
formSection.hidden = formSection.hidden;
}
-(void)addFormRow:(XLFormRowDescriptor *)formRow beforeRow:(XLFormRowDescriptor *)beforeRow
{