【问题标题】:how can XLForm add two BooleanCheck importing mutex relationshipXLForm如何添加两个BooleanCheck导入互斥关系
【发布时间】:2016-04-04 14:58:22
【问题描述】:

我在表单中添加了两个 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;
    }
}

【问题讨论】:

    标签: ios xlform


    【解决方案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];
    }
    

    【讨论】:

      猜你喜欢
      • 2018-06-09
      • 2017-08-19
      • 2020-08-29
      • 1970-01-01
      • 2015-10-19
      • 1970-01-01
      • 2015-04-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多