XLForm 表单提交

来源:互联网 发布:江西财经大学网络 编辑:程序博客网 时间:2024/06/15 06:03

XLForm 据说这个库特别屌,前几天项目需求大量的表单提交类似下图的表单有15 个页面。。。


2596697-e68549805c3552c0.png


开始上代码....

1.导入#import "XLForm.h"2.继承@interface LSXMessageSetupVC : XLFormViewController3.创建-(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";//textViewNSString *const XLFormRowDescriptorTypeTextView = @"textView";//邮政编码NSString *const XLFormRowDescriptorTypeZipCode = @"zipCode";//pushNSString *const XLFormRowDescriptorTypeSelectorPush = @"selectorPush";//ipod(使用)NSString *const XLFormRowDescriptorTypeSelectorPopover = @"selectorPopover";//sheetNSString *const XLFormRowDescriptorTypeSelectorActionSheet = @"selectorActionSheet";//AlertViewNSString *const XLFormRowDescriptorTypeSelectorAlertView = @"selectorAlertView";//pickNSString *const XLFormRowDescriptorTypeSelectorPickerView = @"selectorPickerView";//cell insertNSString *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--------



作者:Lsx_f
链接:http://www.jianshu.com/p/cd881a8f7c5d
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
原创粉丝点击