I have UIViewController with vertical UIScrollView that has UIView as a container for all it's subviews. Here are my scrollView & contentView constraints:
scrollView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
scrollView.widthAnchor.constraint(equalTo: view.safeAreaLayoutGuide.widthAnchor).isActive = true
scrollView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
contentView.centerXAnchor.constraint(equalTo: scrollView.centerXAnchor).isActive = true
contentView.widthAnchor.constraint(equalTo: scrollView.widthAnchor).isActive = true
contentView.topAnchor.constraint(equalTo: scrollView.topAnchor).isActive = true
contentView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor).isActive = true
When I scroll down my navigation bar gets smaller as it should be:
Then I click on tableviewcell, navigate to detailVC and back. That's where the problem comes in. Somehow my navigation bar gets big until I scroll it in any direction, and then it jumps to it's normal state. Why is that happening and what could be the reason?
Here is the gist with my ViewController code
Thanks!
I configured my constraints and fixed that issue.
New constraints:
scrollView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
scrollView.widthAnchor.constraint(equalTo: view.safeAreaLayoutGuide.widthAnchor).isActive = true
scrollView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
contentView.topAnchor.constraint(equalTo: scrollView.topAnchor).isActive = true
contentView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor).isActive = true
contentView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor).isActive = true
contentView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor).isActive = true
// contentView.heightAnchor.constraint(equalTo: scrollView.heightAnchor).isActive = would be true if horizontal
contentView.widthAnchor.constraint(equalTo: scrollView.widthAnchor).isActive = true