2012-04-20 18 views
0

URLと一緒にパラメータとしてidを送る必要があります。次に、プログラムは非同期に画像をダウンロードし、画像をuitableviewセルに表示する必要があります。これを達成するにはどうすればいいですか?私はIDに応じてプロフィール画像をダウンロードして、uitableviewセルに表示する必要があります

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

    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"lisn"]; 

     cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"lisn"] autorelease]; 


    [[cell textLabel] setFont:[UIFont systemFontOfSize:14.0]]; 
    switch([indexPath section]){ 
     case 0: 
      cell.textLabel.text=[arryList objectAtIndex:indexPath.row]; 
      CGRect memberFrame=CGRectMake(240,18,10,30); 
      UILabel *members=[[[UILabel alloc] initWithFrame:memberFrame ] autorelease]; 
      members.text=[arryList objectAtIndex:indexPath.row + 3]; 
      [cell.contentView addSubview:members]; 

      break; 
     case 1: 

      [email protected]"Start date:"; 
      CGRect dateFrame=CGRectMake(80,6,180,20); 
      UILabel *sDate=[[[UILabel alloc] initWithFrame:dateFrame] autorelease]; 
      sDate.text=[arryList objectAtIndex:indexPath.row + 1 ]; 
      [cell.contentView addSubview:sDate]; 
      [email protected]"End date:"; 
      CGRect enddateFrame=CGRectMake(80,22,180,50); 
     UILabel *eDate=[[[UILabel alloc] initWithFrame:enddateFrame] autorelease]; 
      eDate.text=[arryList objectAtIndex:indexPath.row + 2]; 
      [cell.contentView addSubview:eDate]; 

      break; 
     case 2: 
      cell.textLabel.text=[arryList objectAtIndex:indexPath.row + 4]; 

      break; 
     case 3: 
      cell.imageView.image = [UIImage imageNamed:@"ic_place_holder_small.png"]; 
      break; 
     break; 
    } 

    return cell; 
} 

答えて

0

これは私が同様の問題のために使用したものされています:ここで私はこれまで持っているものである

static NSString *CellIdentifier = @"FlickrPhotoCell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

OFPhotoModel *photo = [self.photos objectAtIndex:indexPath.row]; 

cell.textLabel.text = photo.title; 
if (photo.thumbnail) 
    cell.imageView.image = photo.thumbnail; 
else { 
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ 
     if (!photo.thumbnail) { 
      photo.thumbnail = [OFManager thumbnailForPhoto:photo]; 
      dispatch_async(dispatch_get_main_queue(), ^{ 
       [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone]; 
      }); 
     } 
    }); 

    cell.imageView.image = [UIImage imageNamed:@"placeholder.png"]; 
} 

return cell; 

は、この実装は除いて動作することを考えてみましょう(サムネイルはセルにロードするための画像です) - 配列がクリアされて再読み込みされます。少しでも変更は可能です。 - 行の並べ替えはできません(この場合、オブジェクトの新しいindexPathを追跡する必要があります)

+0

ご回答いただきありがとうございます。もう一度感謝してくれてありがとう –

関連する問題