I'm having trouble disabling a UIButton in my UITableViewCell. 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. However the button trashButton
does not seem to disable even when I set it to false. 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.userInteractionEnabled = false
更改为
cell.trashButton.enabled = false
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.