PLATFORM AND VERSION:
- iOS
Development environment:
- Xcode 15.2
- macOS 13.6.3
- iOS 17.2
DESCRIPTION OF PROBLEM
Using a UICollectionView
with compositional layout, once the view is created, programmatically scroll to a row using the scrollToItem
method.
- For this report I created a simple dataSource with 400 rows and 1 section.
- Scrolling to row 200 in
viewDidLoad
orviewWillAppear
after callingcollectionView.layoutIfNeeded()
. - The compositional layout's
orthogonalScrollingBehavior
is set to.groupPagingCentered
The collectionView behaves as expected and shows row 200.
Issue
The issue is that when swiping too quickly to go to row 199 or prior the entire collectionView is reset to row 0. This does not happen when swiping to go on row 201 or above.
STEPS TO REPRODUCE
- Run the app on iPhone.
- Swipe right quickly (to go to row prior to 200)
- Expected result: row 199 or 198 is shown
- Actual result: collectionView is reset to row 0