I have a view controller I present with a navigation controller, and its main content changes based on the data the app has. So if theres no data, I display an empty state screen, if there is data I display a table controller. The empty state and table view are both separate controllers and I add them as children when needed. This seems to not work well with iOS 11s large titles and search controllers to hide them on scrolling. I can't find any information about it either.
Here's my navigation item / bar setup
navigationItem.largeTitleDisplayMode = .automatic
navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.title = NSLocalizedString("LISTS_TITLE", comment: "Lists")
navigationItem.hidesSearchBarWhenScrolling = true
and this is my code for adding / removing child controllers
private func setContentViewController(_ viewController: UIViewController) {
for child in childViewControllers {
child.willMove(toParentViewController: nil)
child.view.removeFromSuperview()
child.removeFromParentViewController()
}
addChildViewController(viewController)
let contentView = viewController.view!
contentView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(contentView)
view.bringSubview(toFront: contentView)
viewController.didMove(toParentViewController: self)
/
var constraints = [NSLayoutConstraint]()
constraints.append(contentView.leadingAnchor.constraint(equalTo: view.leadingAnchor))
constraints.append(contentView.trailingAnchor.constraint(equalTo: view.trailingAnchor))
constraints.append(contentView.topAnchor.constraint(equalTo: view.topAnchor))
constraints.append(contentView.bottomAnchor.constraint(equalTo: view.bottomAnchor))
view.addConstraints(constraints)
}
If anyone has seen this as well, I'd apprechiate the help.