在Swift中禁用没有UserInteractionEnabled的单元格选择

Ada*_*ung 2 ios swift

我有一个带按钮的单元格,设置UserInteractionEnabled为false也会禁用该按钮.现在,如果我使用cell.selectionStyle = UITableViewCellSelectionStyle.None.虽然单元格没有突出显示,但我松开了之前选择的单元格.有什么方法可以解决这个问

小智 10

实现UITableView委托方法

tableView(_ tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath?
Run Code Online (Sandbox Code Playgroud)

返回nil您不希望被选中的行.