Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop UITableView from clipping UITableViewCell contents in iOS 7

Tags:

ios

ios7

As I updated an app of mine from iOS6 to iOS7 I noticed that where in iOS6 cell content was allowed to cross outside of a cell when the clipsToBounds property is set to NO on the cells view or contentView, iOS7 seems to disable this even when the overall view, tableview, cell and cellcontent clipsToBounds are all set as NO. You can see a sample of this in the included images. The first is test code running on iOS6, and the second is the same code running on iOS7:

A sample of this running on iOS6Identical code running on iOS7 Does anyone know how to fix this issue? I'm guessing it's just a one-line fix, but I've spent several hours on this with no luck. To avoid a major rewrite and headaches I'd, but playing around with the view, tableview, cell and cellcontent clipsToBounds has been fruitless - all are set to NO still on iOS7, so I'm not sure what is happening differently.

You can see and download the sample project at: https://github.com/Jon-Schneider/ClipsToBoundsTest

Thanks!

like image 535
jonschneider Avatar asked Sep 18 '13 16:09

jonschneider


2 Answers

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"); } 
like image 143
rjowens Avatar answered Sep 23 '22 00:09

rjowens


You may made chang in the tableview attributes inspector of Clip Subviews.

enter image description here

like image 26
Cao Yong Avatar answered Sep 26 '22 00:09

Cao Yong