ios – UICollectionView scrollToItem not working in .rightToLeft app


I have an app that uses a UICollectionView (collectionView) and uses scrollToItem to move between different cells. It works fine when the language is .leftToRight. It doesn’t work when the language is .rightToLeft.

In the particular case I have there are only two cells (there used to be more, but things were removed from the app). So it should be simple.

I can see that after I call scrollToItem in some cases cellForItemAt is being called with the new index only to immediately be called with the old index as part of the same refresh cycle. In some cases it is never called with the new index.

I played around with all sorts of ways of manipulating the rightToLeft behavior of a UICollectionView (including the collectionFlowLayout).