我的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