From 12bab71b1785056f9dae37c56cce4d773ae6c201 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 14 Oct 2024 18:24:47 -0400 Subject: [PATCH] Remove UITabBarController workaround on iOS 18.1 --- .../Main/NewMainTabBarViewController.swift | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Tusker/Screens/Main/NewMainTabBarViewController.swift b/Tusker/Screens/Main/NewMainTabBarViewController.swift index 3b7c32a0..6d989ddc 100644 --- a/Tusker/Screens/Main/NewMainTabBarViewController.swift +++ b/Tusker/Screens/Main/NewMainTabBarViewController.swift @@ -454,15 +454,20 @@ extension NewMainTabBarViewController { extension NewMainTabBarViewController: UITabBarControllerDelegate { func tabBarController(_ tabBarController: UITabBarController, shouldSelectTab tab: UITab) -> Bool { if tab.identifier == Tab.compose.rawValue { - let currentTab = selectedTab - // returning false for shouldSelectTab doesn't prevent the UITabBar from being updated (FB14857254) - // returning false and then setting selectedTab=tab and selectedTab=currentTab seems to leave things in a bad state (currentTab's VC is on screen but in the disappeared state) - // so return true, and then after the tab bar VC has finished updating, go back to currentTab - DispatchQueue.main.async { - self.selectedTab = currentTab + if #unavailable(iOS 18.1) { + let currentTab = selectedTab + // returning false for shouldSelectTab doesn't prevent the UITabBar from being updated (FB14857254) + // returning false and then setting selectedTab=tab and selectedTab=currentTab seems to leave things in a bad state (currentTab's VC is on screen but in the disappeared state) + // so return true, and then after the tab bar VC has finished updating, go back to currentTab + DispatchQueue.main.async { + self.selectedTab = currentTab + } + compose(editing: nil) + return true + } else { + compose(editing: nil) + return false } - compose(editing: nil) - return true } else if let selectedTab, selectedTab == tab, let nav = selectedViewController as? any NavigationControllerProtocol {