aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Tay <nick@windblume.net>2022-03-18 17:18:19 +1100
committerNicholas Tay <nick@windblume.net>2022-03-18 17:18:19 +1100
commit34531178eb042f5bc1439bce5b6dde543fbb96ab (patch)
tree5632cb8d7688677e4efaa59ea0fa8aea04457d65
parentedd350814f47b5c528a0d0cb415a76ed551c1bf2 (diff)
downloadforayios-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 '')
-rw-r--r--foray/Base.lproj/Main.storyboard19
-rw-r--r--foray/ForayTableViewController.swift18
2 files changed, 29 insertions, 8 deletions
diff --git a/foray/Base.lproj/Main.storyboard b/foray/Base.lproj/Main.storyboard
index dd31919..a655965 100644
--- a/foray/Base.lproj/Main.storyboard
+++ b/foray/Base.lproj/Main.storyboard
@@ -15,6 +15,19 @@
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="60" estimatedRowHeight="-1" sectionHeaderHeight="28" estimatedSectionHeaderHeight="-1" sectionFooterHeight="28" estimatedSectionFooterHeight="-1" id="PLM-PE-uRW">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <prototypes>
+ <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="LNG-Dh-h32">
+ <rect key="frame" x="0.0" y="44.5" width="414" height="60"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="LNG-Dh-h32" id="bGl-Iz-uI9">
+ <rect key="frame" x="0.0" y="0.0" width="414" height="60"/>
+ <autoresizingMask key="autoresizingMask"/>
+ </tableViewCellContentView>
+ <connections>
+ <segue destination="8GL-ME-btj" kind="show" identifier="ShowDetailsSegue" id="RNI-y7-uAc"/>
+ </connections>
+ </tableViewCell>
+ </prototypes>
<sections/>
<connections>
<outlet property="dataSource" destination="wzT-eD-ghF" id="VID-cT-ap6"/>
@@ -40,19 +53,19 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="aBf-Zs-Jkz">
- <rect key="frame" x="0.0" y="134" width="414" height="200"/>
+ <rect key="frame" x="0.0" y="178" width="414" height="200"/>
<constraints>
<constraint firstAttribute="height" constant="200" id="hSS-D1-lO9"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aP2-hq-U5p">
- <rect key="frame" x="16" y="60" width="382" height="42"/>
+ <rect key="frame" x="16" y="104" width="382" height="42"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="35"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="6" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="odL-rc-3m5">
- <rect key="frame" x="16" y="366" width="382" height="20.5"/>
+ <rect key="frame" x="16" y="410" width="382" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
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")
+ }
}
}