2013-06-13 1 views
3

UITableViewCell 사용자 정의 SDWebImage 라이브러리를 사용하려고합니다.사용자 정의 UITableView 셀 이미지가있는 SDWebImage

- (void) downloadThumbnails:(NSURL *)finalUrl 
{ 
    SDWebImageManager *manager = [SDWebImageManager sharedManager]; 
    [manager downloadWithURL:finalUrl 
        options:0 
        progress:nil 
        completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) 
    { 
     if (image) 
     { 
      // do something with image 
      // THERE I HAVE TO ASSIGN the property "thumbnail" with the "image" 
      // So it can be used by the tableview controller class 
     } 
    }]; 

} 

위의 코드는 RSSItem라는 별도의 파일에 : 다음은 웹 서비스에서 이미지를 다운로드하는 방법입니다.

가 가 가

누군가가 지적 할 수있는 방법 내가 만약 (이미지)를 구성 할 수 있습니다

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"ItemsCell"; 

    ItemsViewCell *cell = (ItemsViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    RSSItem *item = [[channel items] objectAtIndex:[indexPath row]]; 

    cell.titleLabel.text = [item title]; 
    cell.creatorLabel.text = [item creator]; 
    cell.pubTimeLabel.text = [item pubTime]; 
    cell.thumbContainer.image = [item thumbnail]; 

    return cell; 
} 
downloadThumbnails 방법 내부 : 내 UITableViewController 클래스는 다음 cellForRowAtIndexPath 방법을 가지고 있지만? 난 그냥 속성 "축소판 그림"에 "이미지"를 할당해야합니다, 어떻게 그럴 수 있습니까?

+0

다운로드가 끝나면 사용 코드를 보여주십시오. –

+0

@NAQ 나는 당신이 요구 한 것을 얻지 못했습니다. 그러나 SDWebImage없이 작동하는 데 사용한 업데이트를 추가했습니다. 희망하시는 답변을 – AJ112

+0

각 이미지의 URL을 어디에 저장합니까? –

답변

4

이미 SDWebImage를 사용하여 비동기 적으로 이미지를 다운로드하는 것처럼 보입니다. 축소판 속성을 "이미지"로 설정하면됩니다. 수행 방법은 다음과 같습니다.

- (void) downloadThumbnails:(NSURL *)finalUrl 
{ 
    SDWebImageManager *manager = [SDWebImageManager sharedManager]; 
    [manager downloadWithURL:finalUrl 
        options:0 
        progress:nil 
        completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) 
    { 
     if (image) 
     { 
      [self setThumbnail:image]; 
     } 
    }]; 

} 
관련 문제