iOS 11 prefersLargeTitles not updating until scroll

前端 未结 24 2357
轻奢々
轻奢々 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:30

    I had a similar issue with navigation bar, but in my case it had a custom title view, and navigation bar remained empty until table view is scrolled down, which triggered UILayoutContainerView to layout its subviews, one of which are navigation controller's view and navigation bar. I assume the root of it is the same as the large title navigation bar issue.

    Anchoring tableView to the safeAreaLayoutGuide didn't work out for me, largeTitleDisplayMode couldn't be other then .never

    So I managed to fix it by calling self.navigationController?.view.setNeedsUpdateConstraints in the top presented controller's viewDidAppear(animated:) function, or scheduling this call for the next run loop in viewWillAppear(animated:), like:

    DispatchQueue.main.async {
        self.navigationController?.view.setNeedsUpdateConstraints()
    }
    

    In this case, navigation bar appeared with the correct content and size along with presenting transition, instead of popping in after transition was completed

提交回复
热议问题