Ios 如何在tableview单元格中禁用按钮但不禁用当前按钮?

Ios 如何在tableview单元格中禁用按钮但不禁用当前按钮?,ios,swift,Ios,Swift,我有一个tableview,在tableview中我有一个按钮,我想禁用其他按钮一秒钟,因为点击按钮时会发生一些后台过程,但在此期间,我想禁用其他按钮如何实现这一点 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "

我有一个tableview,在tableview中我有一个按钮,我想禁用其他按钮一秒钟,因为点击按钮时会发生一些后台过程,但在此期间,我想禁用其他按钮如何实现这一点

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "InnerOptionsCell") as! ProfileInnerOptionsTableViewCell
    cell.selectionStyle = .none
    var dictionary = [String: Any]()
    dictionary = accountList[indexPath.row]
    
    cell.myButton.tag = indexPath.row
    if dictionary["status"] as? Bool ?? false {
        cell.myButton.isEnabled = true
    } else {
        cell.myButton.isEnabled = false
    }
    
    return cell
}

假设当您点击按钮时,您更新了保存在
accountList
中的所有对象,您可以在tableView的
visibleCells
上循环并更新状态,例如

func updateButtons(){
guard let indexPaths=tableView.indexPathsForVisibleRows-else{
返回
}
索引
.map{($0,tableView.cellForRow(at:$0)as?ProfileInnerOptions TableViewCell)}
.forEach{(indexPath,cell)在
cell?.button.isEnabled=accountList[indexPath.row]?[“状态”]为?Bool??false
}
}
您可以在将模型设置“所有状态”更新为
false
后调用类似于上述的函数,然后再将状态设置为
true