-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?

guenis
  • 2,520
  • 2
  • 25
  • 37
  • Try cell.contentView.clipsToBounds = YES; (this is a guess) – danh Mar 07 '13 at 00:21
  • Got a screenshot? The "cell" is the full width of the table (i.e. it includes the grey bits at the left/right). – tc. Mar 07 '13 at 00:24

1 Answers1

0

Update: My previous answer was wrong. Here is an answer that actually shows how to do what you're asking.

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

.......

Previous Answer

If you're adding views to the cell's contentView (which you should be, unless you have a good reason), you'll want to set cell.contentView.clipsToBounds = YES;

Community
  • 1
  • 1
Josh Hudnall
  • 1,021
  • 8
  • 16