DanielDC
DanielDC

Reputation: 1

prefersLargeTitles not working as expected when used with a UITableView added to a subview

I am currently using two viewControllers to design the following layout presented. It is constituted by a MainController defined in the Storyboard with only a view as a subview, and a programmatically added CustomController to this subview that inflates it's own view through a xib file. CustomController only has a tableview as childview.

MainController has the navigationBar attached. In CustomController viewDidLoad(), I set prefersLargeTitles to true and it doesn't work as expected when the tableView is scrolled. Title doesn't collapse when tableview scrolled up nor expands when tableview scrolled down.

image

Currently I can implement this behaviour only when MainController directly has the tableview as it's first childview:

image

But I need to be able to use this behavior using CustomController for app architecture issues.

My guessing, is the inner mechanics of tableview scrolling aren't passed to it's parent navigationController for some reason.

Is there some reference that I need to pass? Maybe modifying the view stack?

Upvotes: 0

Views: 411

Answers (1)

Himan Dhawan
Himan Dhawan

Reputation: 924

Apple recommends to only show large titles in main views. If your viewcontroller has sub-sections make sure to set navigationItem.largeTitleDisplayMode = .never either in code or in your storyboard.

In addition problems arise if you need to customize your view around your table. Usually you create a UIViewController for this and then add the views and tableView as required. If the tableView is not the first view in your storyboard, the large title fails to hide automatically.

enter image description here

Upvotes: 1

Related Questions