GCD를 사용하여 내 uitableview의 이미지를 비동기 적으로로드하고 있지만 문제가 있습니다 - UITableview를 스크롤 할 때 이미지가 맨 위에 표시되지 않습니다. 때때로 이미지가 표시되지 않습니다. UITableviewcell. 이게 내 코드 야. 생각 좀 해줘. 내 코드에 오류가있어. 제발 도와 줘.비동기 GCD를 사용하여 이미지를로드하는 방법 UITableviewcell/
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *[email protected]"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"identifier"];
}
image=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 300, 80)];
[cell.contentView addSubview:image];
str=att.classimage;
[email protected]"My URL";
if(str!=nil){
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(queue, ^(void) {
dispatch_async(dispatch_get_main_queue(), ^{
NSString *imageStr=[url stringByAppendingString:str];
image.image = [UIImage imageNamed:imageStr];
});
});
image.image=[UIImage imageNamed:@"nav-bar-logo.png"];
}
return cell;
}
당신이 큐에서 제거하는 데 사용하는 셀 식별자는 @ "세포"및 식별자 ALLOC/INITING 셀 동안 @ "식별자". – chandu
imageView를 추가하는 방법이 달라졌습니다. 현재 cellForRow가 호출되는 동안 항상 추가됩니다. – Joshua
이미지가 서버에서 오는 경우 이미지 캐시를 제안합니다. – Leena