In a UITabBarController, its controllers are set to be UINavigationControllers. When programmatically setting the selectedViewController to a desired controller which is not currently displayed, the selected icon is correct however the actual view controller is still the previously selected.
Pseudo code:
tabController.controllers = [viewcontroller1, viewcontroller2, viewcontroller3].map{ UINavigationController(rootViewController: $0) }
....
// let's say at some point tab bar is set to e.g. showing index 1
tabController.selectedController = tabController.controllers[0]
// after this the icon of the 1st tab is correctly displayed, but the controller is still the one at index 1
I have noticed that if the controllers are simple UIViewController (not UINavigationController) upon setting the selectedViewController
the TabController sets both icon and content correctly.
But this is not the wanted setup and different UINavigationControllers are needed.
Is this a new bug in iOS18?
Any idea how to fix this (mis)behaviour?