Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Can';t禁用UITableViewCell中的UIButton_Ios_Swift_Uitableview_Uibutton - Fatal编程技术网

Ios Can';t禁用UITableViewCell中的UIButton

Ios Can';t禁用UITableViewCell中的UIButton,ios,swift,uitableview,uibutton,Ios,Swift,Uitableview,Uibutton,我在禁用UITableViewCell中的UIButton时遇到问题。代码如下: func disableAddAudio(reEnable: Bool = false) { headerView.recordButton.userInteractionEnabled = reEnable ? true : false for index in 0...audioViewModelArray.count - 1 { let cell =

我在禁用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标题视图中的按钮,则不会出现任何问题。但是按钮
trashButton
似乎没有禁用,即使我将其设置为false。你知道我可能做错了什么吗?

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

cell.trashButton.enabled = false

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

cell.trashButton.enabled = false

试试这个。如果不是nill,它将禁用该按钮


cell.trashButton.enabled=false

试试这个。如果不是nill,它将禁用该按钮

cell.trashButton.enabled=false

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

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

当我第一次创建自定义UITableViewCell时,我遇到了类似的问题。。。。。我想如果您在cellForRow中设置cell.trashButton.userInteractionEnabled=false,它应该可以正常工作……您在cellForRow中启用了该按钮了吗?可能是单元可重用性的问题。@Bhavik刚刚检查过。不。未在我的代码中的任何其他位置设置启用或禁用。您可以通过更改颜色或从superview中删除该按钮进行检查。如果这样做不起作用,那么问题就出现在tableview逻辑中。我在第一次创建自定义UITableViewCell时遇到了类似的问题。。。。。我想如果您在cellForRow中设置cell.trashButton.userInteractionEnabled=false,它应该可以正常工作……您在cellForRow中启用了该按钮了吗?可能是单元可重用性的问题。@Bhavik刚刚检查过。不。未在我的代码中的任何其他位置设置启用或禁用。您可以通过更改颜色或从superview中删除该按钮进行检查。若那个不起作用,那个么问题是tableview逻辑中的某些东西。这就解决了。非常感谢。我的愚蠢之处在于忽略了这一点,并使用了dequeueReusableCellWithIdentifier。这就做到了。非常感谢。我的愚蠢之处在于忽略了这一点并使用了dequeueReusableCellWithIdentifier。