UITabBarController ignores UITab view controllers when in UITabGroup

When composing tabs like this and selecting them in the sidebar, only the group's view controller is ever displayed, even when selecting the individual first and second tabs. Their view controllers are just ignored. Am I immensely stupid here or is this a bug in iPadOS 26 beta 3?

// First tab
        let firstTab = UITab(
            title: "First",
            image: UIImage(systemName: "heart"),
            identifier: "hello"
        ) { _ in
            UINavigationController(rootViewController: ViewController())
        }

        // Second tab
        let secondTab = UITab(
            title: "Second",
            image: UIImage(systemName: "heart"),
            identifier: "hello2"
        ) { _ in
            UIViewController()
        }
        
        // Tab group
        let tabGroup = UITabGroup(
            title: "Stuff",
            image: nil,
            identifier: "stuff",
            children: [firstTab, secondTab]
        ) { _ in
            ViewController()
        }
        
        let tbc = UITabBarController(tabs: [tabGroup])
        tbc.mode = .tabSidebar
Answered by Frameworks Engineer in 850013022

By default, UITabBarController will only change the view controller for root tabs. Apps can manage how the view controller hierarchy changes within that root tab through system callbacks from UITabBarControllerDelegate.

Setting managingNavigationController on UITabGroup will opt-in the specified group to allow UITabBarController to automatically manage its hierarchy for you.

See this forum comment which has a deeper explanation on how managingNavigationController works, and how you can customize the stack that is built in.

You can also watch Make your UIKit app more flexible from WWDC25 which also explains how this API works with examples.

Accepted Answer

By default, UITabBarController will only change the view controller for root tabs. Apps can manage how the view controller hierarchy changes within that root tab through system callbacks from UITabBarControllerDelegate.

Setting managingNavigationController on UITabGroup will opt-in the specified group to allow UITabBarController to automatically manage its hierarchy for you.

See this forum comment which has a deeper explanation on how managingNavigationController works, and how you can customize the stack that is built in.

You can also watch Make your UIKit app more flexible from WWDC25 which also explains how this API works with examples.

Thanks! So I was dumb, though the documentation could be a bit clearer on this.

Why is this tab showing up even though it should only be in the sidebar? Happens on both phone and iPad in compact size classes, does not happen for the iPad top tab bar.

collectionsTabGroup = UITabGroup(title: "Collections", image: nil, identifier: "collections", children: [])
collectionsTabGroup.managingNavigationController = UINavigationController()
collectionsTabGroup.preferredPlacement = .sidebarOnly

Seems like UITabBarController.compactTabIdentifiers is the way to go to hide certain tabs. But how in the world can I have a UITabGroup "Collections" which collapses back into the "Library" tab when in compact size?

UITabBarController ignores UITab view controllers when in UITabGroup
 
 
Q