ScrollView partially hidden by navigation bar (large titles)
When we force refresh using the HeadRefresh (with NormalHeaderAnimator), when the scrollView populates with cells (in my case is a collectionView) the first cell is partially hidden behind the navigation bar, but after touching/scrolling the scrollView the collectionView automatically snaps itself on the correct position and the bug is gone.
After headRefresh finishes to load the data:

After touching/scrolling the collectionView:

Has anyone experienced this before? How can I fix it?
Hey! You can mention a user like this: @Mattesackboy. If you create an example project in which I can reproduce the error, I will try to help you.
@BarredEwe I've tried to mention you, but without success because you were not on the discussion thread/a collaborator to the project. By the way thanks for your time ❣️ Right now I'm at work, but as soon as possible I'll try to reproduce this on a Test project and send it to you! Thanks again 🙏🏻
Hey @BarredEwe, I've tried to simulate this problem on a Test environment (because I'm sorry but I can't share the whole project where this bug is present) but unsuccessfully. I could, by the way, find the cause of this bug. The ViewController where this happens uses a UICollectionView as root-view (UICollectionViewController) with a Flow layout. On the initializer we have this code:
init(layout: UICollectionViewLayout = UICollectionViewFlowLayout()) {
super.init(collectionViewLayout: layout)
if let layout = layout as? UICollectionViewFlowLayout {
layout.scrollDirection = .vertical
layout.sectionInset = .init(top: 16, left: 16, bottom: 16, right: 16)
layout.minimumInteritemSpacing = 0
layout.minimumLineSpacing = 16
layout.itemSize = .init(width: collectionView.frame.width - 16*2, height: 180)
}
}
By removing the layout.sectionInset = .init(top: 16, left: 16, bottom: 16, right: 16) line, the bug is gone.
Here are 2 videos that demonstrate the problem with the relative fix:
With section inset active (set to: .init(top: 16, left: 16, bottom: 16, right: 16)):
https://user-images.githubusercontent.com/39104425/111219807-b588be80-85d8-11eb-99f5-bddab133dcb4.MP4
Without section inset active:
https://user-images.githubusercontent.com/39104425/111219837-bd486300-85d8-11eb-8475-fda15b7d4d34.MP4
I've also tried it on the simulator, and this bug doesn't happen on it. It happens only on real devices (such as my iPhone X) and only on iOS 14+ (this was not present last year on iOS 13, and we didn't update the app since then).
I may have found a fix to this. Instead of setting the layout.sectionInset (UICollectionViewFlowLayout) top and bottom insets, I need to set the collectionView.contentInset instead. In my case, this can be done easily because I don't have multiple sections on the collectionView, but if someone would have multiple sections could experience the same bug.