How to Stop Uitableview from Clipping Uitableviewcell Contents in iOS 7

How to stop UITableView from clipping UITableViewCell contents in iOS 7

It looks like the view hierarchy changed slightly in iOS 7 for table view cells.

You can try setting the clips to bounds on the contentView's superview:

[cell.contentView.superview setClipsToBounds:NO];

If you add the following to your sample code and run on ios7 vs ios6, you'll see there's an additional view between the cell view and content view:

[cell.contentView.superview setClipsToBounds:NO];
NSLog(@"%@", cell.contentView.superview);
NSLog(@"%@", cell.contentView.superview.superview);
NSLog(@"%@", cell);

if (self.view.clipsToBounds) {
NSLog(@"Master clips");
} else {
NSLog(@"Master no clip");
}

iOS 7.1 UitableviewCell content overlaps with ones below

The issue has to do with the height of your cell. It isn't going to dynamically adjust that for you.

You'll probably notice that as you scroll and the view above goes out of view the overlapping text will disappear with it.

If you are wanting your text to clip at a certain height, then you need to set the number of lines, rather than setting it to 0 since that will let it continue forever.

The lineBreakMode won't take effect since it isn't stopped.

Optionally you could try to set clipping on the contentView to make sure all subviews stay inside.

Depending on the end result you want, you could do dynamic heights and change based on the content. There are a bunch of SO questions related to doing this.

Update - clipping the contentView

I'd have to try it out myself, but in lieu of that, here are a couple links related to clipping the contentView:

  • stop the clipping of contentView - you'd actually want to do the opposite.
  • adding subview - looks similar to what you are trying to do.

Looks like this works:

cell.clipsToBounds = YES;

UITableViewCell not clipping to bounds in editing mode in iOS8 (works in iOS7.1)

Looks like the UITableView in iOS 8 set cell.contentView.clipToBounds to NO when begin editing. This code help me resolve your issue:

- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.contentView.clipsToBounds = YES;
}

UITableView inside UITableViewCell cutting from the bottom

When the table view is asking you to estimate the row height, you are calling back the table view. Thus you are not providing it with any information it doesn't already have.
The problem is probably with your async loading image, so you should predict the image size and provide the table view with properly estimated row height when the image hasn't loaded yet.

UITableview cell reinitializing every time in iOS 7

You just don't store any data in the table view cell but in the model that fills the table cell. This is always the way it should be done.

Looking from the MVC standpoint than the UITableViewCell is a view. Since it is reused by iOS you should use a model to the view.

Cannot set clipToBounds on UITableViewCell's contentView in iOS 7.1

As discussed in the comments, the only solution right now in iOS7.1 is to set clipsToBounds on the cell itself.



Related Topics



Leave a reply



Submit