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