2015-08-25 35 views
2

我正在使用swift通用应用程序。基础是一个SplitViewController。 tableview嵌入在SplitViewController的详细视图中。 UITableViewCells的背景颜色看起来与预期不同 - 但仅限于iPad。我尝试了以下设置:UITableViewCell在运行时看起来不同于InterfaceBuilder(在iPad上)

的TableView在故事板: TableView in Storyboard

层次的看法:

Settings of the cell

设置:

细胞

Hierarchy of the views

设置内容视图:

Settings of the content view

这里是我的代码为 “的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 
    } 

而且实现代码如下看起来在模拟器是这样的:

simulator of tableview

如上所述 - 它看起来正确如果我选择一个iPhone设备作为模拟器。这里是来自iPhone模拟器的图片: iphone version of tableview

我不知道为什么它在iPad上是白色的而不是在InterfaceBuilder中定义的深灰色(就像在iPhone上一样)?没有什么是“选择”.....我总是使用任何/任何大小类。我在这里奋斗了几天

我很高兴为每一个提示。

在此先感谢。 丹尼尔

+0

在iPhone和iPad上运行时发布图片 – Lamar

+0

您确定表格视图在iPad上有单元格也许白色是桌面视图本身不是单元格@myknack –

+0

请检查您的UITableViewCell背景颜色和单元格contentView背景颜色。可能是你离开了这个视图背景颜色 – bhanu

回答

2

注意,通常有(仍然)在故事板一个错误,即使是在Xcode7,

你必须设置细胞码的背景色,也​​不会从故事板工作

class YourCell:UITableViewCell 
    { 
    override func awakeFromNib() 
     { 
     super.awakeFromNib() 
     self.backgroundColor = UIColor.clearColor() 
     } 

    } 

您可能还有其他问题,但这是一个问题。

相关问题