0
我的按钮正常工作,我无法弄清楚如何在水龙头上禁用它。我不确定是否可以从addSomething(sender:UIButton)函数引用它,例如我引用sender.tag。 有什么想法?谢谢你的帮助。在swift中禁用水龙头上的tableview单元按钮
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let myCell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! ExploreCell
// Configure the cell...
myCell.configureCell(teams[indexPath.row])
myCell.addSomethingButton.tag = indexPath.row
myCell.addSomethingButton.addTarget(self, action: #selector(self.addSomething), forControlEvents: .TouchUpInside)
myCell.addSomethingButton.enabled = true
//disable cell clicking
myCell.selectionStyle = UITableViewCellSelectionStyle.None
return myCell
}
感谢您的全力以赴,但放在适当的位置后,它似乎只做你的检查时,tableview加载不是单击按钮之后。 – user3712837
它很简单,答案已经通过在按钮的目标中添加“tableView.reloadData()”进行编辑:) –
啊,谢谢!这很好用!我也循环查看数据库之前已经添加的数组,并且他们工作得很好。 – user3712837