我遇到这些表的问题。我需要为每个@interface ViewController ()
{
IBOutlet UITableView *viewsTbl;
IBOutlet UIButton *addBtn;
NSMutableArray *countArr;
NSMutableDictionary *dataArr;
NSInteger number;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
countArr = [NSMutableArray array];
dataArr = [NSMutableDictionary dictionary];
[dataArr setValue:@"" forKey:@"TextFieldOne"];
[dataArr setValue:@"" forKey:@"TextFieldTwo"];
[countArr addObject:dataArr];
// Do any additional setup after loading the view, typically from a nib.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return countArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ViewTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"ViewTableViewCell"];
if (cell == nil) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"ViewTableViewCell" owner:self options:nil] objectAtIndex:0];
}
if (countArr.count == indexPath.row+1)
{
cell.buttonPlus.hidden = NO;
}
else
{
cell.buttonPlus.hidden = YES;
}
NSDictionary *dict = countArr[indexPath.row];
cell.txtFldOne.text = dict[@"TextFieldOne"];
cell.txtFldTwo.text = dict[@"TextFieldTwo"];
cell.txtFldTwo.delegate = self;
cell.txtFldOne.delegate = self;
cell.txtFldOne.tag = indexPath.row;
cell.txtFldTwo.tag = indexPath.row+1000;
[cell.buttonPlus addTarget:self action:@selector(plusBtnClick) forControlEvents:UIControlEventTouchUpInside];
[cell.buttonMinus addTarget:self action:@selector(minusBtnClick:) forControlEvents:UIControlEventTouchUpInside];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 150;
}
-(void)plusBtnClick
{
dataArr = [NSMutableDictionary dictionary];
[dataArr setValue:@"" forKey:@"TextFieldOne"];
[dataArr setValue:@"" forKey:@"TextFieldTwo"];
[countArr addObject:dataArr];
[viewsTbl reloadData];
}
-(IBAction)minusBtnClick:(id)sender
{
CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:viewsTbl];
NSIndexPath *indexPath = [viewsTbl indexPathForRowAtPoint:buttonPosition];
NSLog(@"%@",indexPath);
[countArr removeObjectAtIndex:indexPath.row];
[viewsTbl reloadData];
if (countArr.count == 0)
{
addBtn.hidden = NO;
viewsTbl.hidden = YES;
}
else
{
addBtn.hidden = YES;
viewsTbl.hidden = NO;
}
}
-(IBAction)addBtnClick:(id)sender
{
dataArr = [NSMutableDictionary dictionary];
[dataArr setValue:@"" forKey:@"TextFieldOne"];
[dataArr setValue:@"" forKey:@"TextFieldTwo"];
[countArr addObject:dataArr];
addBtn.hidden = YES;
viewsTbl.hidden = NO;
[viewsTbl reloadData];
}
计算(af_escalaItem[valor]*af_servprod_criterios[peso])
,但我似乎无法做到这一点。
请参阅下面的图片以便更好地理解。
提前谢谢。
答案 0 :(得分:2)
如果表格之间的关系设置正确,您可以使用RELATED()
函数计算列:
Multiple = RELATED(af_escalaItem[valor]) * RELATED(af_servprod_criterios[peso])
编辑:
由于表之间的关系包含复合键,因此需要使用以下函数来查找peso
的值:
Multiple =
RELATED(af_escalaItem[valor]) *
CALCULATE(
VALUES(af_servprod_criterios[peso]),
FILTER(
af_servprod_criterios,
af_avaliacaoItens[af_criterio_id] = af_servprod_criterios[af_criterio_id] &&
RELATED(af_fornecedorAvalia[af_servprod_id]) = af_servprod_criterios[af_servprod_id]
)
)
结果: