diff options
author | Nicholas Tay <nick@windblume.net> | 2022-03-18 17:18:19 +1100 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2022-03-18 17:18:19 +1100 |
commit | 34531178eb042f5bc1439bce5b6dde543fbb96ab (patch) | |
tree | 5632cb8d7688677e4efaa59ea0fa8aea04457d65 /foray/ForayTableViewController.swift | |
parent | edd350814f47b5c528a0d0cb415a76ed551c1bf2 (diff) | |
download | forayios-34531178eb042f5bc1439bce5b6dde543fbb96ab.tar.gz forayios-34531178eb042f5bc1439bce5b6dde543fbb96ab.tar.bz2 forayios-34531178eb042f5bc1439bce5b6dde543fbb96ab.zip |
Add back in segue to details view
This took a bit to figure out due to the identifier stuff, but we got
there. I'd like to figure out how to push a VC into the navigation
controller though, rather than relying on storyboard segues.
Diffstat (limited to 'foray/ForayTableViewController.swift')
-rw-r--r-- | foray/ForayTableViewController.swift | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/foray/ForayTableViewController.swift b/foray/ForayTableViewController.swift index 2a0188e..295e055 100644 --- a/foray/ForayTableViewController.swift +++ b/foray/ForayTableViewController.swift @@ -158,13 +158,21 @@ class ForayTableViewController: UITableViewController { return "Released in " + dateFormatter.string(from: section.year) } + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + tableView.deselectRow(at: indexPath, animated: true) + performSegue(withIdentifier: "ShowDetailsSegue", sender: indexPath) + } + // MARK: - Navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - let indexPath = tableView.indexPathForSelectedRow! - let item = self.sections[indexPath.section].items[indexPath.row] - - let dvc = segue.destination as! ForayDetailViewController - dvc.selectedItem = item + if segue.identifier == "ShowDetailsSegue" { + let indexPath = sender as! IndexPath + let item = self.sections[indexPath.section].items[indexPath.row] + let dvc = segue.destination as! ForayDetailViewController + dvc.selectedItem = item + } else { + fatalError("unreachable") + } } } |