我有一个表视图和自定义TableViewCell with configure,允许在编辑模式下选择多个单元格,并在我选择单元格时显示复选标记。
tableView.allowsMultipleSelectionDuringEditing = YES
我想在编辑模式中选择单元格时阻止蓝色突出显示。
我尝试了很多方法,例如配置单元格选择样式,但是这样就配置了" check-mark"选择单元格时,不会在编辑模式下显示。
cell.selectionStyle = UITableViewCellSelectionStyleNone;
在这种情况下我真的需要帮助。感谢。
答案 0 :(得分:3)
您可以覆盖自定义tableViewCell的selectedBackgroundView属性 这行代码适合我
[cell setSelectedBackgroundView:[[UIView alloc]initWithFrame:CGRectMake(cell.frame.origin.x, cell.frame.origin.x, cell.frame.size.width, cell.frame.size.height)]];
答案 1 :(得分:2)
一种方法是覆盖单元格中的setHighlighted:animated:
:
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
// do nothing
}
这将阻止突出显示行为,而不是选择行为。可以使用以下方法完全覆盖选择:
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
// update UI for selection state
}
答案 2 :(得分:0)
迅速:
cell.selectedBackgroundView = UIView(frame: cell.frame)
或
cell.selectedBackgroundView.isHidden = true
但是它可能仍然无法按预期工作。选中所有单元格子视图的backgroundColor以清除颜色(透明)后,您可能需要recover it