My large title does shrink normally when scrolled, just like it's supposed to. But, it doesn’t come back large again even when I scroll to the top. When I build the project and open the app for the first time, the large title and search bar appear normally but once it shrinks. It doesn't come back before I finish the app. It happens the same on my device as well.
I am using tableView
with ViewController
, with searchBar
in the navigation title
. I also have tableview header
under the navigation bar.
The way my large title works:
The way it's supposed to work:
I have added a searchController
inside the navigation bar, but I don't think searchController
is the problem because the same problem happens even when I remove the search bar from my project. Also, I have used the same code making large titles in those two different projects in the GIFs, but one works and one doesn't. Why is it?
I put this in the viewDidLoad()
.
navigationController?.navigationBar.prefersLargeTitles = true
I also tried:
navigationItem.largeTitleDisplayMode = .always
But, it didn't work.
I also tried putting:
navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.largeTitleDisplayMode = .always
those two in viewWillAppear()
but it didn't work as well.
-Edit-
The tableView
is the first in the view hierarchy, as well. Please let me know if there's something wrong with the hierarchy.
The image of my document outline:
I looked up what tableview.alwaysBounceVertical
is and what bounce
is in tableview
, and I found out that bounceOnScroll
property was set to false
, which was the reason this problem occured(I guess). The large title
becomes large again when I scroll to the top, after I checked true to bounce on scroll
in the storyboard.
Also, the my large title
works fine without setting bounce vertically
property to true. I tried with both storyboard and in code by setting it to false. So the problem was with only bounceOnScroll
, I guess.
In code, it is okay to put
tableview.bounces = true
on the viewController
.