这里完成新手,并且我试图从tabelViewCell按下按钮时显示它的行号。Swift - 按下UIButton时不调用另一个类的函数
下面是tableViewCell代码:
var myTableViewController: tableViewController?
@IBOutlet var addButton: UIButton!
@IBAction func addButtonPressed(_ sender: Any) {
myTableViewController?.addCellToHome(self) //call add function
}
而且从tableViewController:
func addCellToHome(_ cell: UITableViewCell) //specifies what is to be done when addButton is pressed
{
let row = tableView.indexPath(for: cell)
print(row as! String)
}
有人能告诉我什么,我做错了什么?我在addCellToHome中插入了一个断点,并发现它从来没有被调用过。完成难倒。
在此先感谢。
的可能的复制[iOS的Swift在表视图细胞按钮动作](http://stackoverflow.com/questions/28894765/ios-swift-button-action-in-table-view-cell) – DogCoffee
你确定IBAction被调用吗? – TheValyreanGroup
@TheValyreanGroup是的。在我从tableViewCell的原始代码中,它有'self.addButton.isEnabled = false',当按钮被按下时它变灰。 – qunayu