1
UIImageView가있는 사용자 지정 셀이 있는데 이미지를 표시하지 않습니다. 기본 cell.imageView.image 속성 설정 이미지를 시도하고 잘 작동하지만 내 사용자 지정 ImageView 작동하지 않습니다.UIImageView가있는 사용자 지정 UITableViewCell이 이미지를 표시하지 않습니다.
Xib에서 내 사용자 정의 셀을로드하고 UIImageView를 게으른로드와 관련 있다고 생각합니다. 어떻게 작동하게합니까? 여기 내 코드입니다 :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MyCell";
DVGTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.tag = indexPath.row;
if (self.loader.parsedData[indexPath.row] != nil)
{
cell.imageCustom.image = nil;
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(queue, ^(void) {
NSString *url = [self.loader.parsedData[indexPath.row] objectForKey:@"imageLR"];
NSData *imageData = nil;
if ([self.cache objectForKey:url] != nil)
{
imageData = [self.cache objectForKey:url];
}
else
{
imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
[self.cache setObject:imageData forKey:[self.loader.parsedData[indexPath.row] objectForKey:@"imageLR"]];
}
dispatch_async(dispatch_get_main_queue(), ^{
if (cell.tag == indexPath.row) {
UIImage *image = [[UIImage alloc] initWithData:imageData];
cell.imageCustom.image = image;
[cell setNeedsLayout];
}
});
});
}
return cell;
}
동일한 코드 블록에 대한 질문을 게시하는 데 2 시간의 차이가있을 경우 직접 문제를 해결하기 위해 열심히 노력하지 않습니다. –