我已在我的 cellForRowAt
委托(delegate)中添加了 cell.accessoryType = .disclosureIndicator
,并且还在 viewController
UI 选项中勾选了它“配饰”。我还向 tableView
添加了边距,使其相对于父 View (即设备)的值为 0。
我什至设置了cell.accessoryView?.tintColor = UIColor.black
以防颜色出现问题。但是,我仍然看不到单元格右侧的小箭头。我使用的是默认单元格
。在其他 viewControllers
中我可以使用它,但在这个中却不行。
我检查了单元格和表格 View 的宽度,它们都是 375。
如果我添加自定义图像,它确实有效,如下所示:
let img = UIImage.init(named: "arrow")
cell.accessoryView = UIImageView.init(image: img)
但是,我想要标准箭头。
关于这里可能出现的问题还有更多提示吗?
最佳答案
如果您的目标是 iOS 13,则此操作将不起作用。您可以在 iOS12 上进行验证,但今年早些时候我就遇到了这个问题,解决方案是向单元格添加一个 UIButton,将其限制在屏幕的尾部。
let disclosureButton = UIButton()
disclosureButton.setImage(UIImage(named: "arrow"), for: .normal)
cell.addSubview(disclosureButton)
disclosureButton.translatesAutoresizingMaskIntoConstraints = false
disclosureButton.trailingAnchor.constraint(equalTo: cell.trailingAnchor, constant: -10).isActive = true
disclosureButton.centerYAnchor.constraint(equalTo: cell.centerYAnchor, constant: 0).isActive = true
disclosureButton.widthAnchor.constraint(equalToConstant: 25).isActive = true
disclosureButton.heightAnchor.constraint(equalToConstant: 25).isActive = true
关于swift - tableView 单元格中的披露指示器未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59084877/