Ios UITableView:奇怪的复选标记附件类型行为
介绍我的问题的gif: 在myIos UITableView:奇怪的复选标记附件类型行为,ios,swift,uitableview,Ios,Swift,Uitableview,介绍我的问题的gif: 在myUITableView中,我设置了一个复选标记附件类型,但显示白色背景,而不是单元格的复选标记。复选标记在这里,但为什么我有这个白色背景 我的单元格的染色颜色设置为白色,更改它只需更改复选标记的颜色,背景仍在这里 我的代码: func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if let cell = tableView.cellForRow(at
UITableView
中,我设置了一个复选标记附件类型,但显示白色背景,而不是单元格的复选标记。复选标记在这里,但为什么我有这个白色背景
我的单元格的染色颜色
设置为白色
,更改它只需更改复选标记的颜色,背景仍在这里
我的代码:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let cell = tableView.cellForRow(at: indexPath) as? CheckTableViewCell {
if cell.titleLabel.text != "" {
cell.accessoryType = .checkmark
}
}
}
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
tableView.cellForRow(at: indexPath)?.accessoryType = .none
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as? CheckTableViewCell {
cell.setUp(withTitle: dataSource[indexPath.row].title)
return cell
}
return CheckTableViewCell()
}
func setUp(withTitle title : String){
self.titleLabel.text = title
}
有什么想法吗 我必须在情节提要中将
单元格内容的视图
和UITableView
背景色设置为粉红色,以使其正常工作。显示您的cellForRowAt
方法。