2010-05-31 2 views
0

사용자 지정 UITableViewCell (예 : cell1)을 사용하여 데이터를 표시하는 tableview가 있습니다. 행을 터치하면 사용자 정의 셀이 다른 사용자 정의 UITableViewCell로 변경됩니다 (예 : cell2). 또한 수용 할 셀의 행 크기를 늘려 cell2 항목을 늘립니다.사용자 지정 UITableViewCell 표시 문제가

내 문제는 테이블보기에서 행 수가 적을 때 접근 방식이 잘 작동한다는 것입니다. 행 수가 증가하면 행을 터치하면 확장되지만 표시되는 데이터는 cell1과 동일합니다. Cell2는 전혀로드되지 않는 것 같습니다.

앞으로 곧 답변을 기다리고 있습니다 .... 미리 감사드립니다.

답변

0

내 코드를 게시하고 있습니다. 문제가 있는지 알려주세요.

내 cellForRowAtIndexPath은 다음과 같습니다

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 





    if(indexPath == selectedCellIndexPath) 

    { 



     static NSString *Identifier1 = @"Identifier1"; 

     Identifier1 = @"cell2"; 

     CustomCellController1 *cell = (CustomCellController1 *)[tableView dequeueReusableCellWithIdentifier:Identifier1]; 

     if(cell == nil) { 

      [[NSBundle mainBundle] loadNibNamed:@"CustomCellController1View" owner:self options:nil]; 

      cell = rowTwoObject; 

     } 



     [cell setText:[test1Array objectAtIndex:indexPath.row]];  
     return cell; 



    } 



    else { 





     static NSString *Identifier2 = @"Identifier2"; 

     Identifier2 = @"cell1"; 

     CustomCellController1 *cell = (CustomCellController1 *)[tableView dequeueReusableCellWithIdentifier:Identifier2]; 

     if(cell == nil) { 

      [[NSBundle mainBundle] loadNibNamed:@"CustomCellController1View" owner:self options:nil]; 

      cell = rowOneObject; 

     } 



     [cell setText1:[temp1Array objectAtIndex:indexPath.row]]; 

     [cell setText2:[temp2Array objectAtIndex:indexPath.row]]; 



     return cell; 





    } 



} 

didSelectRowAtIndexPath는 다음과 같습니다

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 



    selectedCellIndexPath = indexPath;  

    [tableView reloadData]; 

} 

heightForRowAtIndexPath은 다음과 같습니다

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 

    if(selectedCellIndexPath != nil 

     && [selectedCellIndexPath compare:indexPath] == NSOrderedSame) 

     return 110; 



    return 60; 
관련 문제