[英]Can't disable UIButton in UITableViewCell
I'm having trouble disabling a UIButton in my UITableViewCell. 我在禁用UITableViewCell中的UIButton时遇到麻烦。 Code is as follows: 代码如下:
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
}
}
here if I disable a button in the UITableView header view there are no issues. 如果禁用UITableView标头视图中的按钮,则没有问题。 However the button trashButton
does not seem to disable even when I set it to false. 但是,即使将我将其设置为false,按钮trashButton
按钮trashButton
也不会禁用。 Any ideas what I might be doing wrong here? 有什么想法我可能在这里做错了吗?
try like this 这样尝试
let cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: index, inSection: 0)) as! AddedAudioTableCell
cell.trashButton.userInteractionEnabled = false
Try this. 尝试这个。 It will disable the button if it is not nill 如果不为空,它将禁用按钮
cell.trashButton.enabled = false cell.trashButton.enabled =否
尝试将这行代码cell.trashButton.userInteractionEnabled = false
更改为
cell.trashButton.enabled = false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.