English 中文(简体)
十三. 口头审理 单元内容观点
原标题:Overlapping UITableViewCell content views

I have this table whose cells look like this: UITabelViewCell
As you can see, the top border of every cell is supposed to overlap with the cell above. Right now, this border is part of the background (no overlapping so far).

现在,我已把边界与背景分开,我的手机制作法也认为:

#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;
}

问题在于,只有当表上出现Im滚动时,边界才会显示出来,否则边界本身就会被上面的牢房重叠。 (错过路)。

I ve Trial [cell setNeedsDisplay] in -tableView:willDisplayCell:forRowAtIndexPath:,在要求设立单位时添加边界(cell-top.png)(这显然会导致多幅绘画和 does;无论怎样,它仍能解决我的问题)和制定

我怎么能强迫UIImage 的意见永远保持下去?

最佳回答

我的建议是,将可识别的言词分类,并压倒排外观,以便把显眼的细胞观点纳入你想要达到的顺序:

- (void)layoutSubviews {
    [super layoutSubviews];
    NSArray *sortedIndexPaths = [[self indexPathsForVisibleRows] sortedArrayUsingSelector:@selector(compare:)];
    for (NSIndexPath *path in sortedIndexPaths) {
        UITableViewCell *cell = [self cellForRowAtIndexPath:path];
        [self bringSubviewToFront:cell];
    }
}

这可能过于缓慢,或者你可能需要修改<条码>,以便:至sendSubview ToBack:,但希望能为你指明方向。

EDIT:现在,如果你重新瞄准S6,那么另一种选择是使用“IDCollectionView”,这为“z-ordering”提供了支持。

问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签