2010-01-06 2 views
1

난 기본 스타일 테이블 (UITableViewCellStyleSubtitle) 전 각 행에 두 개 이상의 detailTextLabel를 추가 할 을 사용하고 기본 하나의 사용자 정의 테이블,
내가 어떻게 그것을 사용자 정의 할 수 있습니다?아이폰 코드 - 대신

코드 :

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) 
{ 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
            reuseIdentifier:CellIdentifier] autorelease]; 
    cell.selectionStyle = UITableViewCellSelectionStyleNone; 
} 

// Leave cells empty if there's no data yet 
if (nodeCount > 0) 
{ 
    // Set up the cell... 
    ARecord *aRecord = [self.entries objectAtIndex:indexPath.row]; 

    cell.textLabel.text = aRecord.lDate; 
    cell.detailTextLabel.text = aRecord.WNum; 

    // Only load cached images; defer new downloads until scrolling ends 
    //(!aRecord.appIcon) - use icon 
    if (!aRecord.appIcon) 
    { 
     if (self.tableView.dragging == NO && self.tableView.decelerating == NO) 
     { 
      [self startIconDownload:aRecord forIndexPath:indexPath]; 
     } 
     // if a download is deferred or in progress, return a placeholder image 
     cell.imageView.image = [UIImage imageNamed:@"Placeholder.png"];     
    } 
    else 
    { 
     cell.imageView.image = aRecord.appIcon; 
    } 

} 

return cell; 

}

답변

2

가장 좋은 방법은 UILabelcell.contentView에 추가하는 것입니다. 처음에 셀을 만들 때 이렇게 할 수 있습니다. 특별히 도움이되는 두 가지 사항을 발견했습니다 : 초기 프레임을 결정하기 위해 인터페이스 빌더의 일회용 문서에있는 표 셀에 레이블을 배치하는 것이 좋습니다. autoresizingMask을 설정하여 셀의 크기를 조정할 때 (자동 회전, 편집 모드로 전환 등) 레이블의 크기가 적절하게 조정되도록하는 것이 특히 유용합니다.

마지막으로 더 큰 셀을 수용하기 위해 테이블보기의 rowHeight을 더 높은 값으로 설정해야합니다. 그렇지 않으면 오버랩하는 셀로 끝납니다.

또한 텍스트를 업데이트 할 때 viewWithTag:으로 쉽게 검색 할 수 있도록 라벨에 tag을 설정하십시오.

0

당신은 cell.contentView에 레이블을 추가 할 수 있습니다.

+0

무엇을 의미합니까? –

관련 문제