5
votes

I have imported UICollectionViewDelege, UICollectionViewDatasource and UIScrollViewDelegate.

I have set my collection views delegate and datasource to self.

But scrollViewDidScroll isnt being called, my scroll view goes horizontal if that makes a difference?

Why is scrollViewDidScroll not being called if collection views use the scrollview inside them?

3

3 Answers

2
votes

I was moving form swift 2 to swift 3 and what did the trick is the following:

swift 2:

public func scrollViewDidScroll(scrollView: UIScrollView)

to swift 3:

public func scrollViewDidScroll(_ scrollView: UIScrollView)

So basically the "_" underscore did the trick. What is annoying is that swift compiler didn't complain about it!!!

As for inheritance UICollectionViewDelegate should do the trick.

1
votes

I had to add information that my controller conforms to UIScrollViewDelegate protocol in order to make it work

-1
votes

I've also encountered this issue. I started off by setting the delegate to self inside of storyboard, at that point scrollViewDidScroll wasn't getting invoked (but functions like collectionView willDisplayCell were, as expected). After some playing around I've noticed that setting delegate programmatically fixed the issue.