2013-03-14 5 views
0

이미지를 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; 
} 
+0

imageView는 사용자 정의 UIImageView입니까? 예, 이름을 변경하거나 셀이 UITableViewCell의 imageView를 사용합니다. – dthien

+0

이름을 변경했지만 여전히 작동하지 않았습니다. 유 다른 코드에서 잘못 볼 수 있니? 고마워 .. – shyamsundar1988

답변

1

다 그래서 dispatch_get_main_queue() 블록의 내부에

[imageView setImageWithURL:imageURL]; 

코드를 삽입 메인 스레드 안에서 처리 될 필요가있다.

+0

안녕하세요, 앤디, 귀하의 회신에 감사드립니다. 나도 그걸 시도해 봤어. 아직도 좋지 않다. SDWebImageCache는 블로그 중 하나에서 자리 표시 자 이미지를 사용한다고 밝혔습니다. 이 경우에도 작동하지 않습니다. – shyamsundar1988

0

내 질문에 답하는 중입니다.

중간 UIImageview를 제거했습니다. 엄지 손톱에 직접 이미지를 설정하는 것이 트릭을 만들었습니다.

관련 문제