나는 그 세포 같이이 테이블을 가지고있다. 지금이 테두리는 배경의 일부입니다 (지금까지 겹치지 않음).중복있는 UITableViewCell 내용보기는
지금, 나는 배경에서 국경을 분리 한 내 세포 생성 코드는 다음과 같습니다
#define QAImage(NAME) [[[UIImageView alloc] initWithImage:[UIImage imageNamed:NAME]] autorelease]
- (UITableViewCell*) tableView:(UITableView*)table cellForRowAtIndexPath:(NSIndexPath*)index
{
UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"Entry"];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"Entry"] autorelease];
cell.backgroundView = QAImage(@"bg-cell.png");
cell.selectedBackgroundView = QAImage(@"bg-cell-sel.png");
cell.selectionStyle = UITableViewCellSelectionStyleGray;
UIImageView *img = QAImage(@"disclosure.png");
img.highlightedImage = [UIImage imageNamed:@"disclosure-sel.png"];
cell.accessoryView = img;
CGRect r = cell.frame;
r.size.height = table.rowHeight;
r.size.width = table.frame.size.width;
cell.frame = r;
r = cell.contentView.frame;
r.origin = CGPointMake(13, 13);
r.size.width -= 8 + img.frame.size.width;
r.size.height -= 25;
[cell.contentView addSubview:[[[TagView alloc] initWithFrame:r] autorelease]];
img = QAImage(@"cell-top.png");
img.highlightedImage = [UIImage imageNamed:@"cell-top-sel.png"];
img.opaque = NO;
r = img.frame;
r.origin = CGPointMake(0, 1 - r.size.height); // The (supposed) overlapping happens here.
img.frame = r;
cell.contentView.clipsToBounds = NO;
[cell.contentView addSubview:img];
}
// Here I set the title. (omitted)
return cell;
}
문제는, 가 경계 만 나는 테이블에 스크롤있을 때 표시됩니다, 그렇지 않으면 그 자체가 그 위의 셀과 중첩됩니다. (약 잘못된 방법입니다.) 나는 -tableView:willDisplayCell:forRowAtIndexPath:
에서 [cell setNeedsDisplay]
을 시도했습니다
, 경계 (cell-top.png
) 분명히 여러 도면을지도하고 잘 보이지 않는 세포가 요청 될 때마다 (추가에 상관없이, 그것은 여전히 아무튼 내 문제를 해결하지 못함) 및 img.layer.zPosition = 2
을 설정하십시오.
UIImageView가 항상 맨 위에 머물 수 있도록하려면 어떻게해야합니까?
대단히 감사드립니다. – Denis
제시의 코드에 몇 가지 오타가 있습니다. NSArray를 수정했습니다. * sortedIndexPaths = [[self indexPathsForVisibleRows] sortedArrayUsingSelector : @selector (compare :)]; (sortedIndexPaths의 NSIndexPath * 경로) { UITableViewCell * cell = [self cellForRowAtIndexPath : path]; [self bringSubviewToFront : cell]; } –
@BenBoral 오타 수정에 감사드립니다! 나는 그것을 그 대답에 통합 시켰습니다. 앞으로는 오타가있을 때 게시물에 "추천"을 할 수 있습니다. 다시 한 번 감사드립니다! –