我在禁用 UITableViewCell 中的 UIButton 时遇到问题。代码如下:
func disableAddAudio(reEnable: Bool = false) {
headerView.recordButton.userInteractionEnabled = reEnable ? true : false
for index in 0...audioViewModelArray.count - 1 {
let cell = tableView.dequeueReusableCellWithIdentifier("AddedAudioTableCellReuseIdentifier", forIndexPath: NSIndexPath(forRow: index, inSection: 0)) as! AddedAudioTableCell
cell.trashButton.userInteractionEnabled = false
}
}
在这里,如果我禁用 UITableView header View 中的按钮,则没有问题。然而,即使我将其设置为 false,按钮 trashButton
似乎也没有禁用。知道我在这里可能做错了什么吗?
最佳答案
这样试试
let cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: index, inSection: 0)) as! AddedAudioTableCell
cell.trashButton.userInteractionEnabled = false
关于ios - 无法在 UITableViewCell 中禁用 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38844798/