iOS在UITableViewCell上与iOS9 iPad发生错误披露背景

iOS在UITableViewCell上与iOS9 iPad发生错误披露背景

问题描述:

我有类似的问题,例如我描述的here。我再次找不到另一个隐藏的设置。iOS在UITableViewCell上与iOS9 iPad发生错误披露背景

我使用披露指标为我的表格视图单元格。并且使用iOS 10+的iPhone/iPad,使用iOS 9的iPhone看起来不错,但不适用于使用iOS 9的iPad。

我试图为accessoryView设置背景,但它仍然是相同的。

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视图零
tableview.background可选(UIDeviceRGBColorSpace 0.976539 0.977373 0.915492 1 )

也试过这样:

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

相同的结果。

任何想法如何解决这个问题?

enter image description here

enter image description here

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

最后我发现,这个问题可以通过初始化backgroundView和背景颜色是固定的:

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

它的工作原理!