0
uitableviewcells에 서브 뷰를 추가했는데 위아래로 스크롤하면 하위 뷰가 여러 번 추가됩니다. 내가 틀린 곳에 나는 안식한다. 당신은 그들이 방금 생성 된 또는 재사용되고 있는지 여부를 셀에 하위 뷰를 추가uitableviewcell의 하위 뷰와 관련된 문제
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"MainPageCellView";
MainPageTableCellView *cell = (MainPageTableCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"MainPageTableCellView" owner:self options:nil];
cell = mainPageTableCell;
}
[cell setNameText:[namesArray objectAtIndex:indexPath.row]];
[cell setPositionText:[positionArray objectAtIndex:indexPath.row]];
[cell setCompanyNameText:[companyNameArray objectAtIndex:indexPath.row]];
[cell setDistanceText:[distArray objectAtIndex:indexPath.row]];
[cell setImageViewImage:[imagesArray objectAtIndex:indexPath.row]];
UIImage *halo = [UIImage imageNamed:@"h1.png"];
UIImageView *haloV = [[UIImageView alloc] initWithImage:halo];
if(indexPath.row == 0)
[cell addSubview: haloV];
else if(indexPath.row ==2)
[cell addSubview: haloV];
else if(indexPath.row ==3)
[cell addSubview: haloV];
return cell;
}
감사합니다 ... 괜찮습니다. ..... – mano
좋습니다. 그것이 맞다면 대답과 upvote를 수락하십시오. –