XLForm 表单提交

作者: Lsx_f | 来源:发表于2017-02-15 10:22 被阅读842次

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


    2596697-e68549805c3552c0.png

    开始上代码....

    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--------

    相关文章

      网友评论

      • 群星盛宴:楼主 我遇到两个问题:1,section怎么设置高度或者不显示,只显示row。2,自定义cell时,如果有表里面还有选择器类型cell,那么点击选择器会调到自定义cell里面的update方法。 请教这个怎么搞?

      本文标题:XLForm 表单提交

      本文链接:https://www.haomeiwen.com/subject/qqtqwttx.html