相关疑难解决方法(0)

如何访问自定义 TableViewCell 中按钮的索引路径?

我创建了一个自定义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'

有关如何访问单元格的索引路径的任何帮助?

button uitableview ios swift

3
推荐指数
1
解决办法
2547
查看次数

标签 统计

button ×1

ios ×1

swift ×1

uitableview ×1