이미지를 UITAbleViewCell에 설정하려고하지만 스크롤하지 않으면 표시되지 않습니다.UItableViewCell에서 이미지가 설정되지 않음 :
반복되는 경우 사과드립니다. 하지만 setNeedsDiplay, reloadRowsinIndexPAth 및 다른 모든 재로드 메서드를 시도했습니다. SDWebImageCache를 사용하여 이미지를 다운로드하고 RayWenderlich's example을 사용하여 가로형 Tableviewcells를 만듭니다. 참조 용으로 코드를 붙여 넣습니다. UI 관련
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ArticleCell";
__block ArticleCell_iPad *cell = (ArticleCell_iPad *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[ArticleCell_iPad alloc] initWithFrame:CGRectMake(0, 0, kCellWidth_iPad, kCellHeight_iPad)];
}
if ([self.articles count] == 0) {
return cell;
}
__block Offer *offer = [self.articles objectAtIndex:indexPath.row];
dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(concurrentQueue, ^{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 201, 201)];
NSURL *imageURL = [NSURL URLWithString: [NSString stringWithFormat:@"%@", offer.image.url]];
[imageView setImageWithURL:imageURL];
dispatch_async(dispatch_get_main_queue(), ^{
[cell.thumbnail setImage:imageView.image];
cell.titleLabel.text = offer.title;
cell.priceLabel.text = [NSString stringWithFormat:@"$%@", offer.regularprice];
});
});
dispatch_release(concurrentQueue);
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
imageView는 사용자 정의 UIImageView입니까? 예, 이름을 변경하거나 셀이 UITableViewCell의 imageView를 사용합니다. – dthien
이름을 변경했지만 여전히 작동하지 않았습니다. 유 다른 코드에서 잘못 볼 수 있니? 고마워 .. – shyamsundar1988