From 1b44117891fd9800363b0adac56af3a6cb57a551 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 14 Dec 2020 22:24:48 -0500 Subject: [PATCH] Don't unnecessarily load views when transferring navigation stacks --- Tusker/Screens/Main/MainSplitViewController.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Tusker/Screens/Main/MainSplitViewController.swift b/Tusker/Screens/Main/MainSplitViewController.swift index a66a0c45..105c534c 100644 --- a/Tusker/Screens/Main/MainSplitViewController.swift +++ b/Tusker/Screens/Main/MainSplitViewController.swift @@ -139,7 +139,9 @@ extension MainSplitViewController: UISplitViewControllerDelegate { // Transfer the nav stacks for all the sidebar items that map 1 <-> 1 with tabs for tab in [MainTabBarViewController.Tab.timelines, .notifications, .myProfile] { let tabNav = tabBarViewController.viewController(for: tab) as! UINavigationController - transferNavigationStack(from: .tab(tab), to: tabNav) + if tabNav.isViewLoaded { + transferNavigationStack(from: .tab(tab), to: tabNav) + } } // Since several sidebar items map to the single Explore tab, we only transfer the @@ -235,7 +237,8 @@ extension MainSplitViewController: UISplitViewControllerDelegate { // For each sidebar item, transfer the existing navigation stasck from the tab bar controller to ourself. var exploreItem: MainSidebarViewController.Item? for tab in MainTabBarViewController.Tab.allCases { - guard let tabNavController = tabBarViewController.viewController(for: tab) as? UINavigationController else { continue } + guard let tabNavController = tabBarViewController.viewController(for: tab) as? UINavigationController, + tabNavController.isViewLoaded else { continue } let tabNavigationStack = tabNavController.viewControllers switch tab {