Hi, I would like to share an issue with UITabBarController's vertical tab bar and iPhone Duo's unfolded pose.
On iPhone Duo (27.2 beta 3), when tab bar controller is added to the view controller while in unfolded pose, the vertical tab bar doesn't appear unless the tab bar controller view's frame is set manually before adding it to the parent's view.
- Show any VC. Use unfolded Duo pose.
- After some time/on button press add a UITabBarController to it: (https://developer.apple.com/documentation/uikit/creating-a-custom-container-view-controller#Add-a-child-view-controller-programmatically-to-your-content) with Auto Layout constraints.
- Vertical tab bar does not appear.
- Fold and unfold the device. The tab bar appears.
Expected: Tab bar appears after adding the UITabBarController in unfolded Duo pose.
Actual: Tab bar does not appear after adding the UITabBarController in unfolded Duo pose.
In Feedback Assistant report (FB25261013) I attached minimal reproduction example and recordings showing the different behavior in folded and unfolded poses and behavior with manual frame application fix (commented out in minimal reproduction example).
Minimal reproduction example:
// SceneDelegate.swift
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 }
window = UIWindow(windowScene: windowScene)
window?.rootViewController = ViewController()
window?.makeKeyAndVisible()
}
}
// ViewController.swift
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .systemBackground
let button = UIButton(configuration: .filled(), primaryAction: UIAction(title: "Show Tab Bar Controller") { [weak self] _ in
self?.showTabBarController()
})
button.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(button)
NSLayoutConstraint.activate([
button.centerXAnchor.constraint(equalTo: view.centerXAnchor),
button.centerYAnchor.constraint(equalTo: view.centerYAnchor),
])
}
private func showTabBarController() {
let tabBarController = UITabBarController()
tabBarController.tabs = ["First", "Second", "Third"].map { title in
UITab(title: title, image: UIImage(systemName: "circle"), identifier: title) { _ in
let viewController = UIViewController()
viewController.view.backgroundColor = .systemBackground
return viewController
}
}
addChild(tabBarController)
// Uncomment to show the tab bar on the unfolded iPhone Duo.
tabBarController.view.frame = view.bounds
view.addSubview(tabBarController.view)
tabBarController.view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
tabBarController.view.topAnchor.constraint(equalTo: view.topAnchor),
tabBarController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
tabBarController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
tabBarController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
])
tabBarController.didMove(toParent: self)
}
}
Thank you in advance.