Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UICollectionView not calling scrollViewDidScroll - Swift

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?

like image 948
Eli Avatar asked Jul 06 '16 23:07

Eli


2 Answers

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.

like image 98
Karim Fikani Avatar answered Oct 23 '22 15:10

Karim Fikani


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

like image 1
Michal Gumny Avatar answered Oct 23 '22 16:10

Michal Gumny