UITableView를 만들려고합니다. 그러나 내 테이블 오류가 스크롤되면 (셀이 숨겨지고 다시 표시 될 때) 탭을 재설정하고 서버에서 이미지를 다시로드합니다. 어떻게하면 이미지를로드하거나 (셀! = 전무) 다음 세포 자체를 반복하면 내가 배치하면 이전의 세포UITableViewCell 스크롤 후 자체 다시로드
static NSString *myIdentifier = @"myIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:myIdentifier];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:myIdentifier];
backImage = [[UIImageView alloc] initWithFrame:CGRectMake(2, 4, 300, 62)];
userDp = [[UIImageView alloc] initWithFrame:CGRectMake(11, 10, 50, 50)];
name = [[UILabel alloc] initWithFrame:CGRectMake(67, 12, 176, 20)];
name.font = [UIFont fontWithName:@"HelveticaLTStd-Bold" size:12];
CustomActivityViewer *imgIndicator = [[CustomActivityViewer alloc] initWithView:userDp];
[imgIndicator startAnimating];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0),^{
UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", IMAGE_URL, player.imagePath]]]];
dispatch_async(dispatch_get_main_queue(), ^{
[imgIndicator stopAnimating];
if (img != nil)
userDp.image = img;
[imgIndicator stopAnimating];
});
});
[name setShadowColor:[UIColor blackColor]];
[name setShadowOffset:CGSizeMake(1, 1)];
name.textColor = [UIColor colorWithRed:1.0 green:0.824 blue:0 alpha:1.0];
cell.accessoryType = UITableViewCellAccessoryNone;
[cell setSelectionStyle:UITableViewCellEditingStyleNone];
cell.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:backImage];
[cell.contentView addSubview:userDp];
[cell.contentView addSubview:name];
return cell;
}
를 유지하지 할 수 있습니다.
어떻게해야합니까?
P.Si iPhone 자습서 중 하나에서 cell.contentView 태그로 항목을 설정 한 다음 셀이 0이 아닌 경우 태그가 포함 된보기를 다시 호출하는 것을 보았습니다. 그 튜토리얼을 찾지 못했습니다. 아무도 모른다면 그냥 넣으십시오.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableView_Class/Reference/Reference.html 'dequeueReusableCellWithIdentifier'에서 서버에서 이미지를 다시 가져 오는 이유는 사라진 테이블 뷰에서 셀을 재사용하고 있기 때문에 다시로드 될 때 이미로드 된 셀에 대한 코드를 실행할 때 UIImage * img = [UIImage imageWithData : [NSData dataWithContentsOfURL : [NSURL URLWithString : [NSString stringWithFormat : @ "% @/% @", IMAGE_URL, player.imagePath]]]]'다시 이미지를 가져옵니다. – Popeye