This is a bit of an odd one, but when using UIKit (I've tried it in SwiftUI and the same result doesn't happen), and attempting to place a UITabViewController as the secondary item in a UISplitViewController, an extra UINavigationBar is presented on the secondary view controller, but only when viewed in its compact form. Selected another tab and revisiting that view fixes the problem. Here are some images - a direct screenshot and one from the view debugger:
Here is my code, I've pulled it out of a larger project but it still is reproducible:
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = scene as? UIWindowScene else { return }
let splitViewController = UISplitViewController(style: .doubleColumn)
let primaryVc = UINavigationController(rootViewController: PrimaryTestUIViewController())
let tabBar = UITabBarController()
tabBar.viewControllers = [UINavigationController(rootViewController: SecondaryTestUIViewController()),
UINavigationController(rootViewController: SecondaryTestUIViewController()),
UINavigationController(rootViewController: SecondaryTestUIViewController())]
let secondaryVC = tabBar
splitViewController.viewControllers = [primaryVc, secondaryVC]
let window = UIWindow(windowScene: windowScene)
window.rootViewController = splitViewController
self.window = window
window.makeKeyAndVisible()
}
}
class PrimaryTestUIViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
title = "Primary view"
}
}
class SecondaryTestUIViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
title = "Secondary view"
}
}