如何阻止 UITableView 在 iOS 7 中剪切 UITableViewCell 内容 [英] How to stop UITableView from clipping UITableViewCell contents in iOS 7

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

问题描述

当我将我的应用程序从 iOS6 更新到 iOS7 时,我注意到当单元格视图或 contentView 上的 clipsToBounds 属性设置为 NO 时,iOS6 单元格内容被允许跨越单元格外部的位置,iOS7 似乎禁用了此功能即使整体视图、tableview、单元格和单元格内容 clipsToBounds 都设置为 NO.您可以在随附的图像中看到这样的示例.第一个是在iOS6上运行的测试代码,第二个是在iOS7上运行的相同代码:

有谁知道如何解决这个问题?我猜这只是一个单行修复,但我已经花了几个小时没有运气.为了避免重大的重写和头痛,我想,但是在视图、tableview、单元格和单元格内容 clipsToBounds 上的尝试是徒劳的 - 在 iOS7 上所有这些都设置为 NO,所以我不确定发生了什么不同的事情.

您可以在以下位置查看和下载示例项目:https://github.com/Jon-Schneider/ClipsToBoundsTest

谢谢!

解决方案

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

您可以尝试将剪辑设置为 contentView 的超级视图的边界:

[cell.contentView.superview setClipsToBounds:NO];

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

[cell.contentView.superview setClipsToBounds:NO];NSLog(@"%@", cell.contentView.superview);NSLog(@"%@", cell.contentView.superview.superview);NSLog(@"%@", 单元格);如果(self.view.clipsToBounds){NSLog(@"主剪辑");} 别的 {NSLog(@"大师无剪辑");}

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:

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!

解决方案

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆