2010-05-11 4 views

답변

1

이 특정 셀에 대한 사용자 지정 셀을 만들어야하지만 reusableCells 덕분에 한 번 인스턴스화됩니다. 예를 들어 :

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{  
    static NSString *CellIdentifier = @"TableCell"; 
    static NSString *ImageIdentifier = @"ImageCell"; 
    UITableViewCell *cell; 

    if (!(indexPath.row % 3)) 
    { 
     cell = [tableView dequeueReusableCellWithIdentifier:ImageIdentifier]; 
     if (cell == nil) 
     { 
      cell = [[[MyCustomCell alloc] initWithDelegate:self reuseIdentifier:(NSString *)ImageIdentifier] autorelease]; 
     }   
    } 
    else 
    { 
     cell = [tableView dequeueReusableCellWithIdentifier:ImageIdentifier]; 
     if (cell == nil) 
     { 
      cell = [[[UITableViewCell alloc] initWithDelegate:self reuseIdentifier:(NSString *)ImageIdentifier] autorelease]; 
     } 

     // customization of your rows here (title, ...) 
    } 

    return cell; 
} 
+0

고마워요!하지만 다른 옵션을 사용했습니다. 당신은 완벽합니다. 코드에 문제가 없습니다. 다시 감사드립니다. –

0

이미지가 표준 UITableViewCell에 비해 너무 크기 때문에 가능하지 않다고 생각합니다. 사용자 정의 셀을 작성한 다음 cellForRowAtIndex 메소드에서 해당 셀을로드해야합니다. 코드/IB에 적절한 cellIdentifier를 설정하는 것을 잊지 마십시오.

어쩌면 UIImageView를 표준 셀의 contentView의 하위보기로 추가 할 수도 있지만,이 방법이 나에게 가장 좋은 솔루션처럼 들리지는 않습니다.

+0

사실 난 것이 가능 알고 있기 때문에에있는 tableview의 - (있는 UITableViewCell *)있는 tableView : (jQuery과 *)있는 tableView cellForRowAtIndexPath : (NSIndexPath *) 우리는 그것을 할 수 있지만, 난 그냥 설정하려면이 코드를 작성하여이 방법 indexPath 그 이미지에 대한 셀의 프레임 cell.image = [UIImage imageNamed : @ "abc.png"]; 하지만 이미지의 셀 프레임을 설정하는 방법을 알려 주시면이 코드는 실제 이미지 크기를 설정할 수 없습니다. 그리고 답장을 보내 주셔서 감사합니다. –

+0

표준 UITableViewCell의 프레임 크기를 변경할 수 있다고 생각하지 않습니다. Thomas Joulin의 코드 샘플이 최상의 옵션입니다. –

0

는 그때 적절한 위임 방법으로 충분한 높이의 셀을 구성하는 세포의 contentView 속성에 하위 뷰 같은 이미지보기를 추가 할 수 있습니다.

관련 문제