2012-03-09 18 views
0

サンプルプロジェクトでLazyTableImageを実装しました。私は1つのセルで3つの画像に表示したい、あなたは私がここでそれを行うことができますが、私のアルゴリズムを作ることができます1セルの3つの画像これは他のプロジェクトで正常に動作しますが、LazyTableImageその動作していない私はそれを行うことができる方法を教えてください...1つのセルに3つの画像を配置する方法

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

    static NSString *CellIdentifier = @"Cell"; 
    static NSString *PlaceholderCellIdentifier = @"PlaceholderCell"; 

    int nodeCount = [self.currentSelectedCategoryArray count]/4; 

    if (nodeCount == 0 && indexPath.row == 0) 
    { 
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier]; 
     if (cell == nil) 
     { 
      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
              reuseIdentifier:PlaceholderCellIdentifier] autorelease]; 
      cell.detailTextLabel.textAlignment = UITextAlignmentCenter; 
      cell.selectionStyle = UITableViewCellSelectionStyleNone; 
     } 

     cell.detailTextLabel.text = @"Loading…"; 

     return cell; 
    } 

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

    int check = indexPath.row; 
    check = check*3; 

     for (int i = 0; i < 3; i++){ 

      if(check+i < [self.currentSelectedCategoryArray count]){ 

       if (nodeCount > 0) 
       { 
        // Set up the cell... 
        imageClass *imgC = [self.currentSelectedCategoryArray objectAtIndex:check+i]; 

        cell.textLabel.text = imgC.imageName; 
        cell.detailTextLabel.text = imgC.imageID; 

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

       } 

      } 

     } 
return cell; 
} 

答えて

1

あなたはcellに1 imageViewしか持っていません。提案された@alan duncanとしてカスタムUITableViewCellを作成する必要があります。あなたのコード内

あなたはこのように持つことができます。

switch(i){ 
    case 0: 
     ((UIImageView*)[cell.contentView viewWithTag:1]).image = imgC.cImage; 
    break; 

    case 1: 
     ((UIImageView*)[cell.contentView viewWithTag:2]).image = imgC.cImage; 
    break; 

    case 2: 
     ((UIImageView*)[cell.contentView viewWithTag:3]).image = imgC.cImage; 
    break; 
} 

を私はあなたのアイデアを得る願っています。

1

は私が独自のペン先でカスタムUITableViewCellを設計します。 3つのUIImageViewインスタンスを視覚的にレイアウトすることができます。

[[UITableViewCell alloc] init...]の代わりに、ペン先から直接セルをロードするか、UINibでインスタンス化します。

関連する問題