iOS 11 prefersLargeTitles not updating until scroll

前端 未结 24 2331
轻奢々
轻奢々 2021-01-31 07:25

I implemented a basic UIViewController with a UITableView that\'s wrapped in a UINavigationController. I set prefersLargeTitles to true:

override fu         


        
相关标签:
24条回答
  • 2021-01-31 08:03

    I had the same problem. Although you are not using Storyboards but I hope this could help someone. I checked "Prefer Large Titles" for the Navigation Controller (not the View Controller) I embedded my TableViewController in. All the View Controllers after the Navigation Controller turned and had large titles, and it should work.

    0 讨论(0)
  • 2021-01-31 08:03

    In my case the solution was to set tableView's top align to Safe Area and not Superview

    0 讨论(0)
  • 2021-01-31 08:03

    Same issue with Swift 5.2

    my view contains tableView and prefersLargeTitles is not updating until scroll, I fixed it by setting

    self.tableView.contentInsetAdjustmentBehavior = .never
    
    0 讨论(0)
  • 2021-01-31 08:04

    That does seem like a weird behavior at first, but try setting the navigationItem.largeTitleDisplayMode to always. The default is automatic - and it's not defined how that works in the docs.

    Also wrote / will update an answer about large titles here.

    0 讨论(0)
  • 2021-01-31 08:04

    Same issue here with Swift 4.2, iOS 12, and refactored Storyboards.

    Tried adding prefersLargeTitles = true to viewWillAppear and viewDidLoad, but neither fixed my issue.

    Instead, I copied the refactored storyboards back into main.storyboard and found the option to enable large titles in IB. Set that option, then refactored the storyboards back out and everything is working now. For some reason, the initial refactoring stripped out the option and I couldn't enable it programmatically.

    0 讨论(0)
  • 2021-01-31 08:05

    I had the same issue and fixed it by changing order of views in my ViewController in InterfaceBuilder.

    It seems like if the first view in Hierarchy is NOT a ScrollView then NavigationBar appears in LargeTitle mode and does not animates together with scroll view. If you need to have Navigation Bar title to reflect your scroll then you need to put your scroll view as the first in view hierarchy.

    Also, I am not completely sure in this but looks like Navigation Bar appearance in standard or Large Title mode depends on views hierarch of previous Controller.

    0 讨论(0)
提交回复
热议问题