有没有机会将一个Integer转换为indexPath?
因为按下按钮时我需要从单元格输出文本.或者我可以使用String作为Button的发送者吗?
cell.uncheckbox.tag = indexPath.row as! IndexPath
cell.uncheckbox.addTarget(self, action: #selector(ViewController.btnClicked), for: UIControlEvents.touchUpInside)
func btnClicked(sender: UIButton)
{
let row = sender.tag
let cell = tableView.dequeueReusableCell(withIdentifier: "LabelCell", for: row) as! TableViewCell;
print("cellentext \(cell.textLabel?.text)")
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
swift3 ×1