1

我在表单中添加了两个 BooleanCheck(A 和 B)。

我希望当我单击 A 时表单可以执行此操作。它的值为 YES;然后我点击B。B值为YES,A为NO。

简单地说,它们只有一个可以被 isChecked

-(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
{
    // super implmentation MUST be called
    [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
    if ([rowDescriptor.tag isEqualToString:@"aCheck"]){
      if(aCheck.value==YES)
          bCheck.value = NO;
        }
    }else if ([rowDescriptor.tag isEqualToString:@"bCheck"]){
      if(bCheck.value==YES)
          aCheck.value = NO;
    }
}
4

1 回答 1

1

我不确定您的 aCheck 和 bCheck 是什么,但想法是在更改受影响的 rowDescriptors 的值后重新加载 tableview 或行

-(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
{
    // super implmentation MUST be called
    [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
    if ([rowDescriptor.tag isEqualToString:@"aCheck"]){
      if(aCheck.value==YES)
          bCheck.value = NO;
        }
    }else if ([rowDescriptor.tag isEqualToString:@"bCheck"]){
      if(bCheck.value==YES)
          aCheck.value = NO;
    }
    //
    // The idea is to reloadData or reload indexPaths
    //
    XLFormRowDescriptor *rowA = [self.form formRowWithTag:@"aCheck"];
    XLFormRowDescriptor *rowB = [self.form formRowWithTag:@"bCheck"];
    NSIndexPath *ipA = [self.form indexPathOfFormRow:rowA];
    NSIndexPath *ipB = [self.form indexPathOfFormRow:rowB];
    [self.tableView reloadRowsAtIndexPaths:@[ipA,ipB] withRowAnimation:UITableViewRowAnimationNone];
}
于 2016-05-02T05:29:41.407 回答