XLForm 据说这个库特别屌,前几天项目需求大量的表单提交类似下图的表单有15 个页面。。。
开始上代码....
1.导入
#import "XLForm.h"
2.继承
@interface LSXMessageSetupVC : XLFormViewController
3.创建
-(void)initializeForm{
// 初始化form 顺便带个title
XLFormDescriptor * formDescriptor = [XLFormDescriptor formDescriptorWithTitle:@"消息提醒"];
// 表单Section对象
XLFormSectionDescriptor * section;
// 表单Row对象
XLFormRowDescriptor * row;
/***********第一个section****************/
section = [XLFormSectionDescriptor formSection];
[formDescriptor addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"ISsound" rowType:XLFormRowDescriptorTypeBooleanSwitch title:@"播放声音"];
if([[USER_DEFAULT valueForKey:@"issound"] isEqualToString:@"yes"]){
row.value=@"YES";
}else{
row.value=@"NO";
}
[section addFormRow:row];
/***********第二个section****************/
section = [XLFormSectionDescriptor formSection];
[formDescriptor addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"ISshock" rowType:XLFormRowDescriptorTypeBooleanSwitch title:@"手机震动"];
if([[USER_DEFAULT valueForKey:@"Isshock"] isEqualToString:@"yes"]){
row.value=@"YES";
}else{
row.value=@"NO";
}
[section addFormRow:row];
self.form=formDescriptor;
}
//设置每行row的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0) {
return 20;
}
return CGFLOAT_MIN;
}
//获取每行的value值
-(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue {
NSLog(@"%@",newValue);
}
//特别提醒:
rowType的类型有好多,可以根据自己的需求选择
//文本
NSString *const XLFormRowDescriptorTypeText = @"text";
NSString *const XLFormRowDescriptorTypeName = @"name";
NSString *const XLFormRowDescriptorTypeURL = @"url";
NSString *const XLFormRowDescriptorTypeEmail = @"email";
NSString *const XLFormRowDescriptorTypePassword = @"password";
NSString *const XLFormRowDescriptorTypeNumber = @"number";
NSString *const XLFormRowDescriptorTypePhone = @"phone";
NSString *const XLFormRowDescriptorTypeTwitter = @"twitter";
//解释
NSString *const XLFormRowDescriptorTypeAccount = @"account";
NSString *const XLFormRowDescriptorTypeInteger = @"integer";
NSString *const XLFormRowDescriptorTypeImage = @"image";
//十进制的
NSString *const XLFormRowDescriptorTypeDecimal = @"decimal";
//textView
NSString *const XLFormRowDescriptorTypeTextView = @"textView";
//邮政编码
NSString *const XLFormRowDescriptorTypeZipCode = @"zipCode";
//push
NSString *const XLFormRowDescriptorTypeSelectorPush = @"selectorPush";
//ipod(使用)
NSString *const XLFormRowDescriptorTypeSelectorPopover = @"selectorPopover";
//sheet
NSString *const XLFormRowDescriptorTypeSelectorActionSheet = @"selectorActionSheet";
//AlertView
NSString *const XLFormRowDescriptorTypeSelectorAlertView = @"selectorAlertView";
//pick
NSString *const XLFormRowDescriptorTypeSelectorPickerView = @"selectorPickerView";
//cell insert
NSString *const XLFormRowDescriptorTypeSelectorPickerViewInline = @"selectorPickerViewInline";
//多选(push 返回的是array)(语言)(以及返回item count)
NSString *const XLFormRowDescriptorTypeMultipleSelector = @"multipleSelector";
//ipod(使用)
NSString *const XLFormRowDescriptorTypeMultipleSelectorPopover = @"multipleSelectorPopover";
//一行双选
NSString *const XLFormRowDescriptorTypeSelectorLeftRight = @"selectorLeftRight";
NSString *const XLFormRowDescriptorTypeSelectorSegmentedControl = @"selectorSegmentedControl";
NSString *const XLFormRowDescriptorTypeDateInline = @"dateInline";
NSString *const XLFormRowDescriptorTypeDateTimeInline = @"datetimeInline";
NSString *const XLFormRowDescriptorTypeTimeInline = @"timeInline";
NSString *const XLFormRowDescriptorTypeCountDownTimerInline = @"countDownTimerInline";
NSString *const XLFormRowDescriptorTypeDate = @"date";
NSString *const XLFormRowDescriptorTypeDateTime = @"datetime";
NSString *const XLFormRowDescriptorTypeTime = @"time";
NSString *const XLFormRowDescriptorTypeCountDownTimer = @"countDownTimer";
NSString *const XLFormRowDescriptorTypeDatePicker = @"datePicker";
NSString *const XLFormRowDescriptorTypePicker = @"picker";
NSString *const XLFormRowDescriptorTypeSlider = @"slider";
NSString *const XLFormRowDescriptorTypeBooleanCheck = @"booleanCheck";
NSString *const XLFormRowDescriptorTypeBooleanSwitch = @"booleanSwitch";
NSString *const XLFormRowDescriptorTypeButton = @"button";
NSString *const XLFormRowDescriptorTypeInfo = @"info";
NSString *const XLFormRowDescriptorTypeStepCounter = @"stepCounter";
--------end--------