Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
UITableViewCell';在iOS 13上,s accessoryView的背景颜色为灰色_Ios - Fatal编程技术网

UITableViewCell';在iOS 13上,s accessoryView的背景颜色为灰色

UITableViewCell';在iOS 13上,s accessoryView的背景颜色为灰色,ios,Ios,我发现在iOS 13上,UITableViewCell的accessoryView具有灰色背景色,但在系统设置中效果良好 我试过设置UITableView背景色和色调,但都不起作用 var cell=tableView.dequeueReusableCell(带有标识符:“myInfo”) 如果(单元格==nil){ cell=UITableViewCell.init(样式:UITableViewCell.CellStyle.default,reuseIdentifier:“myInfo”) }

我发现在iOS 13上,
UITableViewCell的
accessoryView
具有灰色背景色,但在系统设置中效果良好

我试过设置
UITableView
背景色和色调,但都不起作用

var cell=tableView.dequeueReusableCell(带有标识符:“myInfo”)
如果(单元格==nil){
cell=UITableViewCell.init(样式:UITableViewCell.CellStyle.default,reuseIdentifier:“myInfo”)
}
手机!。accessoryType=.disclosureIndicator
Xcode调试层次结构视图中的层次结构:

从系统图像视图看,原因如下:


我的单元格中也存在同样的问题,我的解决方法是继承UITableViewCell,然后在accessoryView中使用自定义图像

self.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_arrow"]];

我也注意到这个问题。即使为accessoryView分配了一个公开指示符,该视图仍然返回nil。我一直在等待苹果解决这个问题,但似乎他们不会很快解决。因此,我在UITableViewCell上创建了一个扩展来处理iOS13和以前的iOS版本

extension UITableViewCell {
    func createCustomCellDisclosureIndicator(chevronColor: UIColor) {
        //MARK: Custom Accessory View
        //Chevron img
        if #available(iOS 13.0, *) {
            let chevronConfig = UIImage.SymbolConfiguration(pointSize: 14, weight: .medium)
            guard let chevronImg = UIImage(systemName: "chevron.right", withConfiguration: chevronConfig)?.withTintColor(chevronColor, renderingMode: .alwaysTemplate) else { return }
            let chevron = UIImageView(image: chevronImg)
            chevron.tintColor = chevronColor

            //chevron view
            let accessoryViewHeight = self.frame.height
            let customDisclosureIndicator = UIView(frame: CGRect(x: 0, y: 0, width: 15, height: accessoryViewHeight))
            customDisclosureIndicator.addSubview(chevron)

            //chevron constraints
            chevron.translatesAutoresizingMaskIntoConstraints = false
            chevron.trailingAnchor.constraint(equalTo: customDisclosureIndicator.trailingAnchor,constant: 0).isActive = true
            chevron.centerYAnchor.constraint(equalTo: customDisclosureIndicator.centerYAnchor).isActive = true

            //Assign the custom accessory view to the cell
            customDisclosureIndicator.backgroundColor = .clear
            self.accessoryView = customDisclosureIndicator
        } else {
            self.accessoryType = .disclosureIndicator
            self.accessoryView?.tintColor = chevronColor
        }
    }
}
我希望这有帮助。下面是两个模拟器的屏幕截图,其中一个运行iOS12.2,另一个运行iOS13。该应用程序名为seventytwo


是否已将
cell.backgroundColor
设置为属性?@HarryJ否…这可能不是问题的直接原因,但调用
tableView.dequeueReusableCell(标识符:)
是错误的。正确的方法是
tableView.dequeueReusableCell(标识符:forindexath:)
。这样,你总是可以得到一个单元格,而不必检查
nil
。这个问题在发布的iOS 13中仍然存在。这是我的作品。救了我一天,谢谢!