0
我嘗試做一個待辦事項應用程序。 我使用的原型單元格,我目前遇到一個問題,當我按下按鈕時,沒有任何反應swift 3原型單元格當前行按鈕
到目前爲止這工作得到按鈕的行。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "LabelCell", for: indexPath) as! TableViewCell
let task = tasks[indexPath.row]
cell.uncheckbox.tag = indexPath.row
cell.uncheckbox.addTarget(self, action: #selector(ViewController.Test), for: UIControlEvents.touchUpInside)
cell.textField.isEnabled = false
cell.importantImage.isHidden = true
if(task.isImportant){
cell.textField?.text = task.name!
cell.importantImage.isHidden = false;
}else{
cell.textField?.text = task.name!
}
return cell;
}
@IBAction func Test(sender: UIButton)
{
let row = sender.tag
let cell = tableView.dequeueReusableCell(withIdentifier: "LabelCell") as! TableViewCell
print(row)
print(row == 0)
if(row == 0){
cell.textField?.text = "change the text"
}
}
的問題是,一旦我按下按鈕沒有任何反應到當前單元格。我想它還沒有設置在正確的行中。
當我剛打印的行,然後按下按鈕,我從按鈕得到正確的值
找到了另一個解決方案! 感謝您的幫助 –
您能否展示您的解決方案?否則對別人沒用 – muescha