I have a UICollectionView
and it has quite a lot of UICollectionViewCells
on it. I want to scroll the cell to the centre of the UICollectionView<
It seems that this bug is caused by a bad interaction between the scroll view's contentInset
and UICollectionViewFlowLayout
. In my testing, setting layout.sectionInset
rather than collectionView.contentInset
eliminated the problem.
Based on the accepted answer above, I would eliminate the workaround, and change:
[collectionView setContentInset:UIEdgeInsetsMake(collectionViewHeight / 2, 0, collectionViewHeight / 2, 0)];
to
[layout setSectionInset:UIEdgeInsetsMake(collectionViewHeight / 2, 0, collectionViewHeight / 2, 0)];