PrefersLargeTitles does not work with software layout

I am trying to add a table view programmatically, but the large title is not displayed.

Here is my code:

self.view.addSubview(module.tableView) module.view.translatesAutoresizingMaskIntoConstraints = false if #available(iOS 11.0, *) { NSLayoutConstraint.activate([ module.view.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: 0), module.view.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor, constant: 0), module.view.leadingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.leadingAnchor, constant: 0), module.view.trailingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.trailingAnchor, constant: 0) ]) } 

Note: large headers are included in the view controller.

 if #available(iOS 11.0, *) { navigationController?.navigationBar.prefersLargeTitles = true navigationItem.largeTitleDisplayMode = .always } 

Perhaps this is important: I'm trying to add a table as a child view controller. My child controller is a UITableViewController. And if I add a child view to viewDidLoad() , a large heading will appear, but it will not scroll.

Here is the link to the file where I add my child module. The detailed code you can see is here in the addChild(module:) method.

Let me know how to fix this error.

+5
source share
4 answers

Include large headers in the viewDidLoad method of the viewDidLoad controller, where you customize the table view.

 if #available(iOS 11, *) { self.navigationController?.navigationBar.prefersLargeTitles = true } 
+1
source

Upgrade your iOS Deployment Target to 11.0 or higher. It is currently at 10.3 . That is why you do not see big titles.

0
source

You should click on the main navigation controller in the navigation bar and then select โ€œPrefers large headersโ€ in the Attributes Inspector. enter image description here

0
source

I am using a software mock and ran into a similar problem. I found a solution here: fooobar.com/questions/203603 / .... In viewDidLoad() I had to turn largeTitleDisplayMode off and on again. This was the right combination, thanks to which large titles worked with scrolling:

 self.navigationItem.largeTitleDisplayMode = .never self.navigationItem.largeTitleDisplayMode = .always 
0
source

Source: https://habr.com/ru/post/1274824/


All Articles