Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScrollView partially hidden by navigation bar (large titles) #51

Open
Mattesackboy opened this issue Mar 14, 2021 · 5 comments
Open

ScrollView partially hidden by navigation bar (large titles) #51

Mattesackboy opened this issue Mar 14, 2021 · 5 comments

Comments

@Mattesackboy
Copy link

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:
photo_2021-03-14 16 57 28

After touching/scrolling the collectionView:
photo_2021-03-14 16 57 31

Has anyone experienced this before? How can I fix it?

@BarredEwe
Copy link

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.

@Mattesackboy
Copy link
Author

@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 🙏🏻

@Mattesackboy
Copy link
Author

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)):

IMG_1753.MP4

Without section inset active:

IMG_1754.MP4

@Mattesackboy
Copy link
Author

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).

@Mattesackboy
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants