Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adjusting UICollectionView scroll speed/sensitivity

I'm trying to slow down the scroll in a UICollectionView. Everything works great and the distance between the cells is fine, but it just moves too fast.

How can I adjust the sensitivity or speed of the scroll?

[Edit] I forgot to mentioned that I already tried:

self.collectionView.decelerationRate = UIScrollViewDecelerationRateFast;

and

self.collectionView.decelerationRate = UIScrollViewDecelerationRateNormal;

With no significant change in speed...

like image 464
MVZ Avatar asked Feb 19 '13 00:02

MVZ


2 Answers

UICollectionView is a subclass of UIScrollView, so you can adjust the decelerationRate in your collection view controller's viewDidLoad, like so:

Objective-C:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.collectionView.decelerationRate = UIScrollViewDecelerationRateFast;
};

Swift:

override func viewDidLoad() {
    super.viewDidLoad()

    self.collectionView.decelerationRate = UIScrollViewDecelerationRateFast
}
like image 93
followben Avatar answered Nov 11 '22 07:11

followben


For anyone looking how to do it in Swift

 self.collectionView.decelerationRate = UIScrollViewDecelerationRateFast

Swift 5:

 self.collectionView.decelerationRate = UIScrollView.DecelerationRate.fast
like image 42
the_pantless_coder Avatar answered Nov 11 '22 07:11

the_pantless_coder