我已经创建了一个自定义的TableViewCell
,并且当前在单元格中放置了一个按钮。当按下按钮时,在tableviewcell.swift
文件中,IBAction func
被执行。我无法弄清楚如何确定按下按钮的单元格的索引路径。我尝试使用以下如何访问自定义TableViewCell中按钮的索引路径?
@IBAction func employeeAtLunch(sender: AnyObject) {
let indexPath = (self.superview as! UITableView).indexPathForCell(self)
println("indexPath?.row")
}
,但我得到的点击以下错误: Could not cast value of type 'UITableViewWrapperView' to 'UITableView'
如何接入小区的索引路径任何帮助吗?
您应该创建一个插座,并把它连接到您的tableView IBOutlet var tableView:UITableView!(您将需要从方法中删除重写) –