我可以成功地使用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 –