2013-03-28 3 views
0

배열에 동적 값이 있습니다. 한 행에 4 개의 값을 표시하고 다른 행에 나머지 값을 표시해야합니다.테이블 뷰의 단일 행에 둘 이상의 값 표시

예 : 배열의 수는, 10

이 행 내 문제는 10

있지만, 1, 2, 3, 4 2 행 5,6,7,8
3 행 9 포함 포함 포함 1

입니다 내가 같이있는 tableview 셀을 가지고 :

1 행 : 1,2,3,4 2 행 : 2,3,4,5 3 행 : 3,4,5,6

내가 노력하고 많은 사물의 정확한 소울리를 얻지 못한다. indexpath에서 행에 대한

세포 :

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; 
     } 

} 

답변

2

당신이

int initialIndex = indexPath.row * 4; 
for (int i=initialIndex ; i<initialIndex+4 && i< totalValues ; i++) 
{ 
    //USE i for getting IndexValue 


} 
처럼 할 수
관련 문제