简体   繁体   English

iOS在使用iOS9的iPad上的UITableViewCell中公开背景错误

[英]iOS Wrong disclosure background in UITableViewCell on iPad with iOS9

I have similar issue like I described here . 我有类似我在这里描述的问题 And again I cannot find another hidden setting. 同样,我找不到其他隐藏设置。

I used disclosure indicator for my table view cell. 我在表视图单元格中使用了公开指示器。 And working on iPhones/iPads with iOS 10+, iPhone with iOS 9 it looks fine, but not on iPad with iOS 9. 在配备iOS 10+的iPhone / iPad,配备iOS 9的iPhone上运行看起来不错,但不适用于配备iOS 9的iPad。

I have tried to set background for accessoryView, but it still the same. 我尝试设置了附件视图的背景,但是仍然相同。

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)

As per print, it's nil: 根据打印,它为零:

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

Also tried this: 还尝试了这个:

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

Same result. 结果相同。

Any idea how to fix this? 任何想法如何解决这个问题?

在此处输入图片说明

在此处输入图片说明

I have found the solution! 我找到了解决方案! Thanks for Claude31 who helped me with with this issue on Apple Developers forum. 感谢Claude31在Apple Developers论坛上帮助我解决了此问题。

Finally I have found that the issue can be fixed by initializing backgroundView and setting colour: 最后,我发现可以通过初始化backgroundView并设置颜色来解决此问题:

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

It works! 有用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM