XLForm 據(jù)說這個(gè)庫特別屌,前幾天項(xiàng)目需求大量的表單提交類似下圖的表單有15 個(gè)頁面。。。

2596697-e68549805c3552c0.png
開始上代碼....
1.導(dǎo)入
#import "XLForm.h"
2.繼承
@interface LSXMessageSetupVC : XLFormViewController
3.創(chuàng)建
-(void)initializeForm{
// 初始化form 順便帶個(gè)title
XLFormDescriptor * formDescriptor = [XLFormDescriptor formDescriptorWithTitle:@"消息提醒"];
// 表單Section對(duì)象
XLFormSectionDescriptor * section;
// 表單Row對(duì)象
XLFormRowDescriptor * row;
/***********第一個(gè)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];
/***********第二個(gè)section****************/
section = [XLFormSectionDescriptor formSection];
[formDescriptor addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"ISshock" rowType:XLFormRowDescriptorTypeBooleanSwitch title:@"手機(jī)震動(dòng)"];
if([[USER_DEFAULT valueForKey:@"Isshock"] isEqualToString:@"yes"]){
row.value=@"YES";
}else{
row.value=@"NO";
}
[section addFormRow:row];
self.form=formDescriptor;
}
//設(shè)置每行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的類型有好多,可以根據(jù)自己的需求選擇
//文本
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";
//十進(jìn)制的
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--------