micco00x
micco00x

Reputation: 149

Know if UICollectionView is scrolling

Is there a way in iOS to know if a UICollectionView is scrolling or not?

I want to know it because I'm loading in every UICollectionCell an image downloaded from the Web, but if the Collection View is big and I scroll until the end it starts downloading every image and if I change view I must wait that previous download, this slow down the app and is not cool, lol :D

Thanks and sorry for my English ;)

Upvotes: 9

Views: 17491

Answers (3)

Monte Hurd
Monte Hurd

Reputation: 4437

As the previous post mentions, UICollectionView inherits from UIScrollView, so I think you can just check a couple UIScrollView methods:

 BOOL isScrolling = (cv.isDragging || cv.isDecelerating);

Edit: As the comment have mentioned, the API is now:

BOOL isScrolling = (cv.dragging || cv.decelerating);

Upvotes: 23

Hiren Panchal
Hiren Panchal

Reputation: 3023

For Swift

let isScrolling: Bool = colView.isDragging || colView.isDecelerating

Upvotes: 5

Josh B.
Josh B.

Reputation: 21

This may help you out since UICollectionView inherits from UIScrollView https://stackoverflow.com/a/19061527/2916429

Upvotes: -1

Related Questions