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