iOS iPad 的 UITableViewCell 中错误的披露背景 iOS9
iOS Wrong disclosure background in UITableViewCell on iPad with iOS9
我遇到了与我描述的类似的问题 。我又找不到另一个隐藏设置了。
我为我的 table 视图单元格使用了披露指示器。在 iPhones/iPads 和 iOS 10+,iPhone 和 iOS 9 上工作看起来不错,但在 iPad 和 iOS 9.
我试过给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 view Optional(UIDeviceRGBColorSpace 0.976539 0.977373
0.915492 1) cell.accessory view nil
tableview.background Optional(UIDeviceRGBColorSpace 0.976539 0.977373 0.915492 1)
也试过这个:
tableView.cellForRow(at: indexPath)?.accessoryView?.backgroundColor = tableView.backgroundColor
同样的结果。
知道如何解决这个问题吗?
我找到解决办法了!
感谢 Claude31 在 Apple Developers 论坛上帮助我解决了这个问题。
最后我发现这个问题可以通过初始化 backgroundView 和设置颜色来解决:
let backgroundView = UIView()
backgroundView.backgroundColor = tableView.backgroundColor
cell.backgroundView = backgroundView
有效!
我遇到了与我描述的类似的问题
我为我的 table 视图单元格使用了披露指示器。在 iPhones/iPads 和 iOS 10+,iPhone 和 iOS 9 上工作看起来不错,但在 iPad 和 iOS 9.
我试过给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 view Optional(UIDeviceRGBColorSpace 0.976539 0.977373 0.915492 1) cell.accessory view nil
tableview.background Optional(UIDeviceRGBColorSpace 0.976539 0.977373 0.915492 1)
也试过这个:
tableView.cellForRow(at: indexPath)?.accessoryView?.backgroundColor = tableView.backgroundColor
同样的结果。
知道如何解决这个问题吗?
我找到解决办法了! 感谢 Claude31 在 Apple Developers 论坛上帮助我解决了这个问题。
最后我发现这个问题可以通过初始化 backgroundView 和设置颜色来解决:
let backgroundView = UIView()
backgroundView.backgroundColor = tableView.backgroundColor
cell.backgroundView = backgroundView
有效!