在切换标签时,在标签栏控制器中使用导航控制器会出现较大的标题故障。
SceneDelegate.swift
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
let tabBarController = UITabBarController()
tabBarController.viewControllers = [UINavigationController(rootViewController: ViewController()), UIViewController()]
window.rootViewController = tabBarController
self.window = window
window.makeKeyAndVisible()
}
ViewController.swift
self.view.backgroundColor = .systemBackground
self.title = "Main"
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationItem.largeTitleDisplayMode = .always
scrollView = UIScrollView(frame: self.view.bounds)
self.view.addSubview(scrollView)
let contentView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 1400))
contentView.backgroundColor = .gray
self.scrollView.addSubview(contentView)
scrollView.contentSize.height = 1700
复制步骤:
当它是表视图或集合视图而不是滚动视图时,不会发生这种情况。
这是在iOS 13中开始发生的。我是否错过了行为上的某些更改,或者这是一个错误?有人知道解决方法吗?