Iglistkit: How to get the contentOffset value from IGListCollectionView?

Created on 17 Feb 2017  路  2Comments  路  Source: Instagram/IGListKit

New issue checklist

General information

  • IGListKit version: 2.1.0
  • iOS version(s): 10.2
  • CocoaPods/Carthage version: 1.2.0.beta.3
  • Xcode version: 8.2 beta
  • Devices/Simulators affected:
  • Reproducible in the demo project? (No):
  • Related issues: #158

For UICollectionView we can get e.g. collectionView.contentOffset.y value from scrollViewDidScroll(_ scrollView: UIScrollView), but is there any way to get a content offset value when using IGListCollectionView?

I need it in order to manipulate constraints and/or view positions on other views based on scroll.
Any help is much appreciated.

I started asking in #158 due to its relevance, but as it's closed I created a new issue. Hope that's okay.

question

Most helpful comment

Thanks @jamieQ, this was embarrassingly simple :)

For others who are as confused as I am, just make sure the adapter is your scrollview delegate by adding adapter.scrollViewDelegate = self and you're good to go.

So then you can do e.g.
func scrollViewDidScroll(_ scrollView: UIScrollView) { print(collectionView.contentOffset.y) }

All 2 comments

@HumidBrains i think you can still receive UIScrollViewDelegate callbacks if you specify an object for the scrollViewDelegate property on your list adapter.

Thanks @jamieQ, this was embarrassingly simple :)

For others who are as confused as I am, just make sure the adapter is your scrollview delegate by adding adapter.scrollViewDelegate = self and you're good to go.

So then you can do e.g.
func scrollViewDidScroll(_ scrollView: UIScrollView) { print(collectionView.contentOffset.y) }

Was this page helpful?
0 / 5 - 0 ratings