我正在尝试根据用户的输入在我的表单中添加更多行。
例如,我有一个字段询问我想要添加到表单中的行数。如果输入为5,则将生成5个附加行并附加到表单。
到目前为止,XLForm可以添加单行(例如多值表单),我在想是否可以批量添加单行,而不是每次只添加一行。
这个是可能的吗?
发布于 2015-07-29 21:55:38
我处理XLForm已经有一段时间了,但我认为像这样的东西会工作得很好:
-(void) formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)formRow oldValue:(id)oldValue newValue:(id)newValue {
[super formRowDescriptorValueHasChanged:formRow oldValue:oldValue newValue:newValue];
NSNumber *newVal = [newValue valueData];
int count = newVal.intValue; //5
for(int i=0; i<count; i++) {
NSString *title = [NSString stringWithFormat:@"title %d",i+1];
XLFormRowDescriptor *row = [XLFormRowDescriptor formRowDescriptorWithTag:title rowType:XLFormRowDescriptorTypeText];
[row.cellConfigAtConfigure setObject:title forKey:@"textField.placeholder"];
[self.form addFormRow:row afterRowTag:someOtherRow.tag];
}
}https://stackoverflow.com/questions/31694452
复制相似问题