我的VC中有一个UITableView,基本上我想要的是它的第一部分是不可打的。但是我不能使用isUserInteractionEnabled
,因为我在本节的每一行中都有UISwitch。设置selectionStyle
到.none
没有任何变化。我只能在界面检查器中选择No Selection
以禁用这些行,但会禁用整个表。我该怎么办?UITableViewCell在点击时突出显示
编辑
这里是我的自定义单元格类
class CustomCell: UITableViewCell { override func setHighlighted(_ highlighted: Bool, animated: Bool) { if if highlighted { self.backgroundColor = ColorConstants.onTapColor } else { self.backgroundColor = .clear } } override func setSelected(_ selected: Bool, animated: Bool) { if selected { self.backgroundColor = ColorConstants.onTapColor } else { self.backgroundColor = .clear } } }
检查:http://stackoverflow.com/questions/2267993/uitableview-how-to-disable-selection-for-some-rows-but-not-others – Priyal