Fix detail navigation controller code

This commit is contained in:
Maurice Parker 2019-07-18 18:49:27 -05:00
parent d01f356869
commit b5411cde42
4 changed files with 44 additions and 13 deletions

View File

@ -207,9 +207,8 @@ class AppCoordinator: UndoableCommandRunner {
rootSplitViewController.delegate = self
masterNavigationController = (rootSplitViewController.viewControllers.first as! UINavigationController)
masterFeedViewController = UIStoryboard.main.instantiateController(ofType: MasterFeedViewController.self)
masterFeedViewController = (masterNavigationController.topViewController as! MasterFeedViewController)
masterFeedViewController.coordinator = self
masterNavigationController.pushViewController(masterFeedViewController, animated: false)
// let detailNavigationController = (rootSplitViewController.viewControllers.last as! UINavigationController)
// detailNavigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem
@ -447,17 +446,18 @@ class AppCoordinator: UndoableCommandRunner {
}
func selectArticle(_ indexPath: IndexPath) {
if let detailNavController = rootSplitViewController.viewControllers.last as? UINavigationController,
let _ = detailNavController.topViewController as? DetailViewController {
if let detailNavigationController = rootSplitViewController.viewControllers.last as? UINavigationController,
let _ = detailNavigationController.topViewController as? DetailViewController {
currentArticleIndexPath = indexPath
} else {
let detailViewController = UIStoryboard.main.instantiateController(ofType: DetailViewController.self)
let detailNavigationController = UIStoryboard.main.instantiateViewController(identifier: "DetailNavigationController") as! UINavigationController
let detailViewController = detailNavigationController.topViewController as! DetailViewController
detailViewController.coordinator = self
detailViewController.navigationItem.leftBarButtonItem = rootSplitViewController.displayModeButtonItem
detailViewController.navigationItem.leftItemsSupplementBackButton = true
currentArticleIndexPath = indexPath
// rootSplitViewController.toggleMasterView()
rootSplitViewController.showDetailViewController(detailViewController, sender: self)
rootSplitViewController.showDetailViewController(detailNavigationController, sender: self)
}
}

View File

@ -19,6 +19,9 @@
<rect key="frame" x="0.0" y="813" width="414" height="49"/>
<autoresizingMask key="autoresizingMask"/>
</toolbar>
<connections>
<segue destination="7bK-jq-Zjz" kind="relationship" relationship="rootViewController" id="Ehy-DL-bQz"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="8fS-aE-onr" sceneMemberID="firstResponder"/>
</objects>
@ -33,7 +36,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<wkWebView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="t8d-md-Yhc">
<rect key="frame" x="0.0" y="44" width="414" height="769"/>
<rect key="frame" x="0.0" y="88" width="414" height="725"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<wkWebViewConfiguration key="configuration">
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
@ -134,7 +137,23 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="FJe-Yq-33r" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="900" y="-23"/>
<point key="canvasLocation" x="2367" y="-83"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="MFb-g9-xHT">
<objects>
<navigationController storyboardIdentifier="SystemMessageNavigationController" id="mTc-f9-2dr" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Ork-ch-DOU">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="Xld-e9-xoL" kind="relationship" relationship="rootViewController" id="E2B-jI-ffd"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="WCE-Jg-o7b" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="154" y="-83"/>
</scene>
<!--System Message-->
<scene sceneID="tbo-yR-QVH">
@ -158,6 +177,7 @@
</constraints>
<viewLayoutGuide key="safeArea" id="zOb-OV-HXy"/>
</view>
<navigationItem key="navigationItem" id="2kf-IY-WDY"/>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="messageLabel" destination="6C9-Jb-ZZR" id="HeR-Qv-yfz"/>
@ -165,7 +185,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="rgH-br-nLG" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1640.5797101449277" y="-23.4375"/>
<point key="canvasLocation" x="874" y="-83"/>
</scene>
<!--Timeline-->
<scene sceneID="fag-XH-avP">
@ -221,7 +241,7 @@
<toolbarItems/>
<connections>
<segue destination="RMx-3f-FxP" kind="relationship" relationship="masterViewController" id="BlO-5A-QYV"/>
<segue destination="vC3-pB-5Vb" kind="relationship" relationship="detailViewController" id="FRG-EO-hQw"/>
<segue destination="mTc-f9-2dr" kind="relationship" relationship="detailViewController" id="3HU-Sb-w7Y"/>
</connections>
</splitViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="cZU-Oi-B1e" sceneMemberID="firstResponder"/>
@ -283,17 +303,21 @@
<scene sceneID="r7l-gg-dq7">
<objects>
<placeholder placeholderIdentifier="IBFirstResponder" id="SLD-UC-DBI" userLabel="First Responder" sceneMemberID="firstResponder"/>
<navigationController storyboardIdentifier="DetailNavigationViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" toolbarHidden="NO" id="vC3-pB-5Vb" sceneMemberID="viewController">
<navigationController storyboardIdentifier="DetailNavigationController" useStoryboardIdentifierAsRestorationIdentifier="YES" toolbarHidden="NO" id="vC3-pB-5Vb" sceneMemberID="viewController">
<navigationBar key="navigationBar" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="DjV-YW-jjY">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<toolbar key="toolbar" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Skn-vK-czG">
<rect key="frame" x="0.0" y="813" width="414" height="49"/>
<autoresizingMask key="autoresizingMask"/>
</toolbar>
<connections>
<segue destination="JEX-9P-axG" kind="relationship" relationship="rootViewController" id="yH5-Bf-My9"/>
</connections>
</navigationController>
</objects>
<point key="canvasLocation" x="154" y="-23"/>
<point key="canvasLocation" x="1619" y="-83"/>
</scene>
</scenes>
<resources>

View File

@ -11,7 +11,7 @@ import UIKit
class SystemMessageViewController: UIViewController {
@IBOutlet weak var messageLabel: UILabel!
var message: String?
var message: String = NSLocalizedString("No Selection", comment: "No Selection")
override func viewDidLoad() {
super.viewDidLoad()

View File

@ -10,6 +10,13 @@ import UIKit
extension UISplitViewController {
static func template() -> UISplitViewController {
let splitViewController = UISplitViewController()
splitViewController.preferredDisplayMode = .allVisible
splitViewController.viewControllers = [UINavigationController()]
return splitViewController
}
func toggleMasterView() {
let barButtonItem = self.displayModeButtonItem
if let action = barButtonItem.action {