3
我想用SDWebImage
庫自定義UITableViewCell
。下面是從Web服務下載圖像的方法:SDWebImage自定義UITableView細胞圖像
- (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
一個單獨的文件。雖然我的UITableViewController
類具有以下cellForRowAtIndexPath
方法:
- (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方法裏面?我只需要將「圖像」分配給屬性「縮略圖」,我該怎麼做?
下載完成時請顯示您的測試代碼? –
@NAQ我沒有得到你所要求的。但是我添加了一個更新如何在沒有SDWebImage的情況下使用。希望它回答你所要求的 – AJ112
你在哪裏存儲每個圖像的URL? –