我正在使用swift的通用应用程序。基础是SplitViewController。 tableview嵌入在SplitViewController的详细视图中。我的UITableViewCells的背景颜色看起来与预期不同 - 但仅限于iPad。我尝试了以下设置:
观点的层次结构:
单元格的设置:
内容视图的设置:
以下是" cellForRowAtIndexPath"的代码:
let tableData = ["Test User 1", Test User 2"]
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("cell") as! UITableViewCell!
cell.textLabel!.text = tableData[indexPath.row]
cell.textLabel?.textColor = UIColor.whiteColor()
cell.textLabel?.font = UIFont(name: "HelveticaNeue-Light", size:
return cell
}
tableview在模拟器中看起来像这样:
如上所述 - 如果我选择iPhone设备作为模拟器,它看起来是正确的。这是来自iPhone模拟器的图片:
我不知道为什么它在iPad上是白色的而不是InterfaceBuilder中定义的深灰色(就像在iPhone上一样)?什么都没有被选中" .....我总是使用任何/任何尺寸等级。我在这里挣扎了好几天
我很满意每一个提示。
提前致谢。 丹尼尔
答案 0 :(得分:2)
请注意,即使在Xcode7中,通常在(故事板)中仍然存在错误,
你必须在代码中设置单元格的背景颜色,它在故事板中不起作用
class YourCell:UITableViewCell
{
override func awakeFromNib()
{
super.awakeFromNib()
self.backgroundColor = UIColor.clearColor()
}
}
您可能还有其他问题,但这是一个问题。