Pétur Pétur - 1 year ago 193
iOS Question

Force UICollectionView to stop scrolling

A user performs a quick swipe gesture to make a UICollectionView start scrolling (it will gradually come to an halt).

How can I programmatically force the scrolling to come to an immediate stop?
To clarify, I want to allow the deceleration but I need to be able to stop it in code.

Answer Source

Have you tried the following?

[self.collectionView setContentOffset:self.collectionView.contentOffset animated:NO];

the contentOffset property is constantly updated as the collectionView scrolls (even via animation) so at the time of calling the above, it should hopefully force the collectionView to stop its existing animation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download