0

我是iOS开发的新手。我FXForm用来创建一个UITableview基于表单。我已经通过设置位域来使用FXFormFieldOptions字段进行多项选择。FXFormFieldType我需要选项列表中选定选项的索引路径。

    @{FXFormFieldKey: @"language",
      FXFormFieldOptions: @[@"English", @"Spanish", @"French", @"Dutch"],FXFormFieldType:FXFormFieldTypeBitfield},

请您提供一些解释或帮助。

4

1 回答 1

0
  1. Have a class which confirms to the protocol <FXForm>
  2. Have a NSInteger property called language in the class you created in step 1
  3. In the class you created in step 1 implement the method - (NSArray *)fields. A sample implementation is shown below.

-(NSArray *)fields

{
    NSArray *basicFields = @[
                             @{FXFormFieldKey: @"language",
  FXFormFieldOptions: @[@"English", @"Spanish", @"French", @"Dutch"]},
                             ];

    NSArray *controlFields = @[
                               @{FXFormFieldTitle: @"Submit", FXFormFieldAction: @"submitTapped:"},
                               ];


    return [basicFields arrayByAddingObjectsFromArray:controlFields];

}
  1. In the view controller you are displaying the form implement the method - (void) submitTapped:(UITableViewCell *)cell as follows.

    -(void) submitTapped:(UITableViewCell *)cell

    {

    YourClassName *form = (YourClassName *)cell.field.form;

    }

You could access the language property of the object form to get the selected index path.

于 2015-03-19T08:26:36.080 回答