I want to implement pull-down-to-refresh in a UICollectionViewController
under iOS 6. This was easy to achieve with a UITableViewController
, like so:>
mjh's answer is correct.
I ran into the issue where if the the collectionView.contentSize
was not larger then the collectionView.frame.size
, you can not get the collectionView
to scroll. You can not set the contentSize
property either (at least I couldn't).
If it can't scroll, it won't let you do the pull to refresh.
My solution was to subclass UICollectionViewFlowLayout
and overide the method:
- (CGSize)collectionViewContentSize
{
CGFloat height = [super collectionViewContentSize].height;
// Always returns a contentSize larger then frame so it can scroll and UIRefreshControl will work
if (height < self.collectionView.bounds.size.height) {
height = self.collectionView.bounds.size.height + 1;
}
return CGSizeMake([super collectionViewContentSize].width, height);
}