【发布时间】:2015-02-24 05:01:53
【问题描述】:
我的问题只出现在 iPad 上。默认情况下,我的容器视图是清晰/透明的。它可以在 iPhone 上正常工作,但在 iPad 上显示时默认为白色背景。大多数自定义 uitableviews 上的问题也是一样的。
我已附上以下问题的图片:
【问题讨论】:
-
感谢您为我添加图片。
标签: ios objective-c swift
我的问题只出现在 iPad 上。默认情况下,我的容器视图是清晰/透明的。它可以在 iPhone 上正常工作,但在 iPad 上显示时默认为白色背景。大多数自定义 uitableviews 上的问题也是一样的。
我已附上以下问题的图片:
【问题讨论】:
标签: ios objective-c swift
这基本上是我的问题的解决方案,我必须添加的唯一内容是使用 tableViewDelegate 的“willDisplayCell”方法。
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
var backgroundView : UIView = UIView(frame: CGRect.zeroRect)
backgroundView.backgroundColor = UIColor.clearColor()
cell.backgroundView = backgroundView
cell.backgroundColor = UIColor.clearColor()
}
【讨论】:
iPad 上单元格的背景颜色有问题。我遇到过这个问题。
我已通过将单元格所有组件的背景颜色更改为代码中的清晰颜色来解决此问题。
//in cell's awakeFromNib
UIView* backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
backgroundView.userInteractionEnabled = NO;
backgroundView.backgroundColor = [UIColor clearColor];
self.backgroundView = backgroundView;
self.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor clearColor];
我觉得this很有帮助
【讨论】:
单元格ContentView 的默认颜色对于iPhone 和iPad 是不同的。
您必须在情节提要中设置Background colour of Cell's ContentView,然后您就完成了。
【讨论】: