我在数组中有动态值。我必须在一行显示4个值,在另一行显示其余值。
例如。
数组的计数为10。
第一行包含1、2、3、4
第二行包含5,6,7,8
第三行包含9、10。
但我的问题是,我将表视图单元格设置为:
第一排:1、2、3、4
第二排:2,3,4,5
第三排:3,4,5,6
我尝试了很多事情,但没有得到确切的灵魂。
索引路径行的单元格:
if (rowcount % 4)
{
for (k=0; k<4; k++)
{
btnexpand = [[UIButton alloc] init];
btnexpand = [UIButton buttonWithType:UIButtonTypeCustom];
btnexpand.frame = CGRectMake(j, 5, 80, 40);
[btnexpand setTitle:[NSString stringWithFormat:@"Step %d",[[[[appDelegate.array_proj objectAtIndex:indexPath.section] arr_task] objectAtIndex:indexPath.row - 1+k] taskid]] forState:UIControlStateNormal];
[cell.contentView addSubview:btnexpand];
j = j + 65;
}
}
else
{
for (k=0; k<rowcount%4; k++)
{
btnexpand = [[UIButton alloc] init];
btnexpand = [UIButton buttonWithType:UIButtonTypeCustom];
btnexpand.frame = CGRectMake(j, 5, 80, 40);
[btnexpand setTitle:[NSString stringWithFormat:@"Step %d",[[[[appDelegate.array_proj objectAtIndex:indexPath.section] arr_task] objectAtIndex:indexPath.row - 1+k] taskid]] forState:UIControlStateNormal];
[cell.contentView addSubview:btnexpand];
j = j + 65;
}
}