I have a UICollectionView that is using groupPagingCentered orthogonalScrollingBehavior to show images in cells, almost one cell for the screen. I have a toolbar that can act on the current image. Because there seems to be no access to the scrollview, I have no way of telling where a user has paged to to act on it.
Is there any way of getting what the user has paged to? (ie: the current centred cell after the user has moved to a new cell)
It seems that Scrollview delegates are not available when using orthogonalScrollingBehavior.
Code Block swift +--------------------------------+ |-+ +------------------------+ +-| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |-+ +------------------------+ +-| +--------------------------------+
Is there any way of getting what the user has paged to? (ie: the current centred cell after the user has moved to a new cell)
It seems that Scrollview delegates are not available when using orthogonalScrollingBehavior.
You can (and should) use the visibleItemsInvalidationHandler on orthogonal sections for the most accurate detail on your current scrolling context.
Code Block swift let section = NSCollectionViewSection(group: group) section.visibleItemsInvalidationHandler = { visibleItems, scrollOffset, environment in /* ... use scrollOffset to determine the paging behaviour */ } /* ...other setup */ let layout = UICollectionViewCompositionalLayout(section: section)