我制作了一个UITableViewCell
带有UIButton
内部的自定义 xib。单元格contentView
内有,而且必须有.isUserInteractionEnabled = True
。我面临的问题是使用时
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("selected row at index: \(indexPath)")
}
的UITableView
函数不会被调用。我已经读过,由于某种原因,我不能didSelectRowAt
在contentView.isUserInteractionEnabled = True
. 这是一种或另一种类型的交易。但是,在我的情况下,我必须有contentView.isUserInteractionEnabled = True
和didSelectRowAt
工作。那么对于这个问题有什么好的解决方法呢?
我已经有了 :
tableView.dataSource = self
tableView.delegate = self