I have a CustomTabBarController with 4 tabs. When I am inside the 3rd tab, let's say I have a screen called A and I have a button which takes me a second screen called B. So, when I am on screen B and I am pressing the 3rd tab, I want to stay on screen B. The current app behaviour is when I am on screen B and I am pressing the 3rd tab, the app navigates to screen A.
Do you know how to solve this issue?
In your
CustomTabBarControllersubclass inherit theUITabBarControllerDelegateprotocol and in yourviewDidLoad()set your controller's delegate toself. Then override thefunc tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Boolmethod returningfalseif the currentselectedViewControllerequals the passed in view controller.