我在表单(A和B)中添加了两个BooleanCheck。
我希望表格可以做到这一点
当我单击A时,其值为YES;
然后我单击B。B的值为YES和A为否。
简而言之,他们只有其中之一可以被检查
-(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;
}
}
最佳答案
我不确定您的aCheck和bCheck是什么,但想法是在更改受影响的rowDescriptors的值后重新加载表视图或行
-(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];
}
关于ios - XLForm如何添加两个BooleanCheck导入互斥关系,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36406146/