Navigation title and navBarItems in UITabbarcontroller is hiding automatically when expanding the collpsed splitview in iPad.
class TabBarController: UITabBarController,UISplitViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let tabTitles = ["First", "Second", "Third", "Fourth", "Fifth", "Sixth"]
if #available(iOS 18.0, *) {
mode = .tabSidebar
var tabs = [UITab]()
for title in tabTitles {
let tab = UITab(title: title, image: UIImage(systemName: "leaf"), identifier: title, viewControllerProvider: {_ in
return self.createSplitViewController()
})
tabs.append(tab)
}
setTabs(tabs, animated: true)
}
}
func createSplitViewController() -> UISplitViewController {
let splitViewController = UISplitViewController()
splitViewController.preferredDisplayMode = .oneBesideSecondary
let masterViewController = UINavigationController(rootViewController: MasterViewController())
let detailViewController = UINavigationController(rootViewController: DetailViewController())
masterViewController.navigationBar.backgroundColor = .red
detailViewController.navigationBar.backgroundColor = .blue
splitViewController.viewControllers = [masterViewController, detailViewController]
return splitViewController
}
}
This issue persist in UITabBarController’s subclass as will as while using UITabBarController as child viewcontroller.https://i.sstatic.net/xF3ekVUi.jpg