本文介绍了如何阻止UITableView剪辑iOS 7中的UITableViewCell内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将iOS6的应用程序更新为iOS7时,我注意到当在单元格视图或contentView上将clipsToBounds属性设置为NO时,iOS6单元格内容允许跨越单元格,iOS7似乎禁用了此功能即使整体视图,tableview,cell和cellcontent clipsToBounds都设置为NO。您可以在附带的图像中看到此示例。第一个是在iOS6上运行的测试代码,第二个是在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:



有谁知道如何解决这个问题?我猜它只是一个单行修复,但我花了几个小时没有运气。为了避免重大的重写和头痛我,但是玩视图,tableview,cell和cellcontent clipsToBounds一直没用 - 所有在iOS7上都设置为NO,所以我不确定发生了什么不同。

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

谢谢!

推荐答案

看起来iOS 7中的视图层次结构在表视图单元格中略有变化。

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

您可以尝试在clipView的superview上设置剪辑边界:

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

[cell.contentView.superview setClipsToBounds:NO];

如果您在示例代码中添加以下内容并在ios7 vs ios6上运行,您将会看到单元格视图和内容视图之间的附加视图:

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");
}

这篇关于如何阻止UITableView剪辑iOS 7中的UITableViewCell内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 21:40