Ios Can';t禁用UITableViewCell中的UIButton
我在禁用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 =
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。