Search code examples
iosswiftxcodeuiscrollviewuiscrollviewdelegate

How do I attach Scroll View's delegate method?


I have collection view which contains a scroll view. Scroll view has custom class which has scrollViewDidScroll function. Whenever I scroll, the scrollViewDidScroll method doesn't trigger.

I tried attaching it's delegate to it's own class, and all the other classes and view controller itself. I attached each scroll view using cellForItemAt function because each controller has it's own cell.


Solution

  • Create custom class of UICollectionView and then make an outlet of scrollview in that class and connect its delegate to it in awakeFromNib: method.