Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ;)

like image 534
micco00x Avatar asked Nov 14 '13 16:11

micco00x


2 Answers

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);
like image 166
Monte Hurd Avatar answered Sep 30 '22 05:09

Monte Hurd


For Swift

let isScrolling: Bool = colView.isDragging || colView.isDecelerating
like image 21
Hiren Panchal Avatar answered Sep 30 '22 06:09

Hiren Panchal