2010-03-27 5 views
6

지금까지 필자는 원하는대로 셀을 만들기 위해 사용자 정의 펜촉을 만들었지 만 이번에는 셀의 높이가 변경되어 하나의 셀을 만들 수 없습니다. 고정 크기 셀의 펜촉입니다.사용자 정의 셀이있는 테이블보기 (프로그래밍 방식으로)

프로그래밍 방식으로 작성하기로 결정했습니다. 달성하기 좋은 방법 아래에있는 방법입니까?

// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
     UILabel *pseudoAndDate = [[UILabel alloc] initWithFrame:CGRectMake(0.0,0.0,320.0,20.0)]; 
     [pseudoAndDate setTag:1]; 
     [cell addSubview:pseudoAndDate]; 
     [pseudoAndDate release]; 
    } 

    CommentRecord *thisRecord = [comments objectAtIndex:[indexPath row]]; 

    UILabel *label = (UILabel *)[cell viewWithTag:1]; 
    [label setText:[NSString stringWithFormat:@"%@ | %@",thisRecord.author,thisRecord.date]]; 

    return cell; 
} 

... 여기에 뭔가가 있습니까?

감사합니다,

고티에) 지금까지이 작동하지 않는 원인.

답변

0

새로운 링크를 달성하기 위해 사용자 지정 UITableViewCell 프로그래밍 방식으로 Apple Documentation UITableViewCell

+0

[링크 전용 답변] (http://meta.stackoverflow.com/tags/link-only-answers/info)은 권장하지 않으므로 SO 답변은 솔루션 검색의 종점이어야합니다. 시간이 지남에 따라 부실 해지는 경향이있는 참조의 또 다른 중간 기착). 링크를 참조로 유지하면서 독립형 시놉시스를 여기에 추가하는 것을 고려해보십시오. – kleopatra

0

왜 필요하지 않을 때 라벨을 만드나요? UITableViewCell의 레이블을 사용하십시오.

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

    static NSString *CellIdentifier = @"Cell"; 

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

    CommentRecord *thisRecord = [comments objectAtIndex:[indexPath row]]; 

    cell.textLabel.text = [NSString stringWithFormat:@"%@ | %@",thisRecord.author,thisRecord.date]; 

    return cell; 
} 
관련 문제