配列に動的な値があります。1 つの行に 4 つの値を表示し、別の行に残りの値を表示する必要があります。
たとえば。配列のカウントは 10 です。
1 行目には 1、2、3、4 が含まれます 2 行目には 5、6、7、8 が含まれます
3 行目には 9、10 が含まれます。
しかし、私の問題は、テーブルビューセルを次のように取得したことです。
1 列目: 1,2,3,4 2 列目: 2,3,4,5 3 列目: 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;
}
}