我可以成功地使用DidSelectRowAtIndexPath
将数据(authorID)传递给视图。 现在我尝试用Button IBACTION执行相同的segue,但是我找不到执行它的方法。我找不到在INACTION中使用NSIndexPath的方法。Swift - IBACTION如何执行segue
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
performSegueWithIdentifier("ArticleSegue", sender: indexPath)
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "ArticleSegue"{
let toView = segue.destinationViewController as! ArticleTableViewController
let indexPath = sender as! NSIndexPath
let authorid = articleList?[indexPath.row]["author_id"].int!
toView.authorid = authorid
}
@IBAction func favButtonDidTouch(sender: AnyObject) {
//???
}
因此你的tableView中的每一行都有favButton?你使用自定义单元格吗? – florianpfisterer
是的,我有一个自定义的单元格,每一行都有favButton –