繁体   English   中英

无法禁用UITableViewCell中的UIButton

[英]Can't disable UIButton in UITableViewCell

我在禁用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标头视图中的按钮,则没有问题。 但是,即使将我将其设置为false,按钮trashButton按钮trashButton也不会禁用。 有什么想法我可能在这里做错了吗?

这样尝试

let cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: index, inSection: 0)) as! AddedAudioTableCell
cell.trashButton.userInteractionEnabled = false

尝试这个。 如果不为空,它将禁用按钮

cell.trashButton.enabled =否

尝试将这行代码cell.trashButton.userInteractionEnabled = false更改为

cell.trashButton.enabled = false

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM