我创建了一个自定义TableViewCell,目前在单元格中放置了一个按钮。当按钮被按下时,在tableviewcell.swift文件中,IBAction func被执行。我无法弄清楚如何确定按钮所在单元格的索引路径被按下。我试图使用以下
@IBAction func employeeAtLunch(sender: AnyObject) {
let indexPath = (self.superview as! UITableView).indexPathForCell(self)
println("indexPath?.row")
}
Run Code Online (Sandbox Code Playgroud)
但是单击时出现以下错误:
Could not cast value of type 'UITableViewWrapperView' to 'UITableView'
有关如何访问单元格的索引路径的任何帮助?