Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS make UICollectionView scrollable with PullToRefreshView

How do you make a UICollectionView scrollable when you only have a few cells?

I've implemented a UICollectionView that lays out cells in the form of a grid. If there's only a few cells, then by default, UICollectionView is not scrollable (all the cells fit in the screen of the phone).

However, I've also implemented a PullToRefreshView. This works perfectly when I have a lot of cells, as the UICollectionView is then scrollable and I can pull and refresh.

What can I do to make the UICollectionView scrollable despite only having a few cells?

Here is how I initialize my PullToRefreshView

self.pull = [[PullToRefreshView alloc] initWithScrollView:self.collectionView];
[self.collectionView addSubview:self.pull];
like image 701
Rohan Agarwal Avatar asked Dec 23 '12 08:12

Rohan Agarwal


1 Answers

Because UICollectionView inherits from UIScrollView, it's as simple as setting self.collectionView.alwaysBounceVertical = YES to get persistent bouncing, no matter how many cells your collection view has.

like image 134
CodaFi Avatar answered Oct 17 '22 00:10

CodaFi