-1

I have a design issue with grouped uitableview, I add uiviews to the leftmost side of each cell extending little over the cell bounds and I want them to be clipped. But neither setting clip subviews in IB nor setting clipsToBounds property in code didn't help.

So far I have set clipsToBounds (for both uitableview itself and individual uitabviewcells) in a number of places but none helped:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    ...
    [cell setClipsToBounds:TRUE];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:defaultIdentifier];

    if (cell == nil)
    {
        cell = [self reuseTableViewCellWithIdentifier:defaultIdentifier withIndexPath:indexPath];
    }
    ...
    [cell setClipsToBounds:TRUE];
    ...
    return cell;
}

- (void)viewDidLoad
{
    ...
    [mainTableView setClipsToBounds:TRUE];
} 

Is it possible without changing tableview style to plain?

4

1 回答 1

0

更新:我之前的回答是错误的。这是一个答案,它实际上显示了如何做你所要求的。

https://stackoverflow.com/a/401271/350467

…………

上一个答案

如果您要向单元格的 contentView 添加视图(除非您有充分的理由,否则您应该这样做),您需要设置cell.contentView.clipsToBounds = YES;

于 2013-03-07T00:40:30.203 回答