获取的UITableView单元格的列上按下按钮迅速3

问题描述:

我有工作SWIFT 2这段代码,它有助于获取的UITableView单元格的行上按下按钮:获取的UITableView单元格的列上按下按钮迅速3

@IBAction func commentsButtonAction(sender: AnyObject) { 
    let btnPos: CGPoint = sender.convert(point:CGPoint.zero, toView: self.tableView) 
    let indexPath: NSIndexPath = self.tableView.indexPathForRow(at: btnPos)! as NSIndexPath 
    passaValor = indexPath.row 
    performSegue(withIdentifier: "searchToComments", sender: self) 
} 

在SWIFT 3我收到此错误

不能调用 '转换' 类型的参数列表 '(点: CGPoint,toView:UITableView的)'

任何想法? 谢谢。

方法的签名已被斯威夫特3.下改变它现在是:

func convert(CGPoint, to: UIView?) 

因此你会称其为:

sender.convert(CGPoint.zero, to: self.tableView) 

试试这个

myButton.addTarget(self, action: "connected:", forControlEvents: .TouchUpInside)) 

你需要这个

myButton.tag = indexPath.row 

func connected(sender: UIButton){ 
    let buttonTag = sender.tag 
} 

希望这会有所帮助。