2017-08-25 84 views
1

我有類似的問題,例如我描述的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

回答

0

我已經找到了解決方案! 感謝Claude31在Apple Developers論壇上幫助我解決了這個問題。

最後我發現,這個問題可以通過初始化backgroundView和背景顏色是固定的:

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

它的工作原理!