It is a little bit of an odd one, however when utilizing UIKit (I’ve tried it in SwiftUI and the identical consequence does not occur), and trying to put a UITabViewController
because the secondary merchandise in a UISplitViewController
, an additional UINavigationBar
is introduced on the secondary view controller, however solely when seen in its compact kind. Chosen one other tab and revisiting that view fixes the issue. Listed here are some photographs – a direct screenshot and one from the view debugger:
Picture of downside on iPhone
Picture of view debugger displaying two tab bars
Right here is my code, I’ve pulled it out of a bigger mission nevertheless it nonetheless is reproducible:
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, choices connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = scene as? UIWindowScene else { return }
let splitViewController = UISplitViewController(model: .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() {
tremendous.viewDidLoad()
title = "Main view"
}
}
class SecondaryTestUIViewController: UIViewController {
override func viewDidLoad() {
tremendous.viewDidLoad()
title = "Secondary view"
}
}