1

我有类似的问题,就像我在这里描述的那样。我再次找不到另一个隐藏的设置。

我为我的表格视图单元格使用了披露指示器。在装有 iOS 10+ 的 iPhone/iPad 上工作,在装有 iOS 9 的 iPhone 上看起来不错,但在装有 iOS 9 的 iPad 上却不行。

我试图为附件视图设置背景,但它仍然是一样的。

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath) as! TablesTableViewCell
    cell.accessoryView?.backgroundColor = tableView.backgroundColor
    if let tablesTable = fetchedResultsController?.object(at: indexPath) {
        currentTableSession = TableSessionTable.getCurrentTableSession(table: tablesTable)
        cell.tableNameLabel.text = tablesTable.tableName
        print("cell.contant view")
        print(cell.contentView.backgroundColor)
        print("cell.accessory view")
        print(cell.accessoryView?.backgroundColor)
        print("tableview.background")
        print(tableView.backgroundColor)

根据打印,它是零:

cell.contant 视图可选(UIDeviceRGBColorSpace 0.976539 0.977373 0.915492 1) cell.accessory 视图 nil
tableview.background 可选(UIDeviceRGBColorSpace 0.976539 0.977373 0.915492 1)

也试过这个:

tableView.cellForRow(at: indexPath)?.accessoryView?.backgroundColor = tableView.backgroundColor

结果相同。

知道如何解决这个问题吗?

在此处输入图像描述

在此处输入图像描述

4

1 回答 1

1

我找到了解决方案!感谢 Claude31 在 Apple Developers 论坛上帮助我解决了这个问题。

最后我发现这个问题可以通过初始化 backgroundView 和设置颜色来解决:

let backgroundView = UIView()  
backgroundView.backgroundColor = tableView.backgroundColor  
cell.backgroundView = backgroundView

有用!

于 2017-09-26T16:22:34.273 回答