【发布时间】:2014-11-27 14:54:31
【问题描述】:
我正在制作一个应用程序,我在 uitableview 单元格中使用复选框。现在我被困在它上面我如何在标签中显示选定复选框的数量。就像我选中一个框,然后在标签中显示“选中的 1 个复选框”,如果我选中 2 个复选框,然后在标签中选中“选中的 2 个复选框”,将显示如何完成任何想法?下面是我处理复选框按钮的代码:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *tableviewidentifier = @"cell";
tablecellTableViewCell *cell= [self.activitiesTableView_ dequeueReusableCellWithIdentifier:tableviewidentifier];
if(cell==nil)
{
cell = [[tablecellTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:tableviewidentifier];
}
UILabel *valuedate = (UILabel *)[cell viewWithTag:11];
UILabel *msg = (UILabel *)[cell viewWithTag:12];
UILabel *date = (UILabel *)[cell viewWithTag:13];
UILabel *time = (UILabel *)[cell viewWithTag:14];
[valuedate setText:@"Demo"];
[msg setText:@"How are You?"];
date.text=@"14/07/2014";
time.text=@"A 08:16";
// [cell.textLabel setText:activityModel.userName];
valuedate.font=[UIFont fontWithName:@"SegoeUI" size:15];
msg.font=[UIFont fontWithName:@"SegoeUI-light" size:10.0];
date.font=[UIFont fontWithName:@"SegoeUI-light" size:9];
time.font=[UIFont fontWithName:@"SegoeUI-light" size:9];
if ([self.checkimageArray containsObject:[self.lblArray objectAtIndex:indexPath.row]])
{
[cell.button setImage:[UIImage imageNamed:@"tick.png"] forState:UIControlStateNormal];
//[cell.button setImage:[UIImage imageNamed:@"uncheck.png"] forState:UIControlStateNormal];
}
else
{
[cell.button setImage:[UIImage imageNamed:@"uncheck.png"] forState:UIControlStateNormal];
}
cell.button.tag=indexPath.row;
[cell.button addTarget:self action:@selector(checkButton:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
【问题讨论】:
标签: ios uitableview checkbox