No UIScrollDelegate in UICollectionView with Compositional Layout

UIScrollDelegate Methods do not get called for horizontal scrolling collectionviews when using compositional layout.


This can be recreated by implementing UIScrollViewDelegate methods in OrthogonalScrollBehaviorViewController from the WWDC example code.


Grateful for any advice, thanks

Replies

If you want we try to reproduce and analyze, thanks to post the relevant code.

Thanks Claude,


It can be reproduced by attempting to implement the UIScrollDelegate functions in example code of this session https://developer.apple.com/videos/play/wwdc2019/215/


I assume that the new compositional layout only implements scrollviewdelegate on vertical layouts. All horizontal scroll get handled by the individual groups and don't inherit UIScrollDelegate


If that is the case then compositionalLayout becomes unusable for situations where you want to be able to use scroll to item at index path or where you want to set decelerationrate on horizontal scrolling UICollectionViews.


It seems instead you are limited to the orthogonal scrolling behaviour properties with no further information about what items are currently in the scope of view or will come into the view.

Thanks for the link, but the video (or pdf) is not the most convenient to extract code…

Well you need to download the sample code from the ressource to the WWDC video i linked to. Here is the direct link to the Ressource. You will need to download the sample code there: https://developer.apple.com/documentation/uikit/views_and_controls/collection_views/using_collection_view_compositional_layouts_and_diffable_data_sources

I downloaded the code.


What do I need to search for ?

- when running the demo app

- in code ?: there is no reference to scrollViewDelegate at all

You will have to implement the UIScrollViewDelegate methods in OrthogonalScrollBehaviorViewController.swift

Hey, wait a minute.

I am not requesting anything on the matter, I have nothing to implement.


If you want people to look at it, provide some code they can analyse, not a link to a large project in which to pick to understand your problem.


Wish you good continuation.

+1