UIRefreshControl on UICollectionView only works if the collection fills the height of the container UIRefreshControl on UICollectionView only works if the collection fills the height of the container ios ios

UIRefreshControl on UICollectionView only works if the collection fills the height of the container


Try this:

self.collectionView.alwaysBounceVertical = YES;

Complete code for a UIRefreshControl

UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];refreshControl.tintColor = [UIColor grayColor];[refreshControl addTarget:self action:@selector(refershControlAction) forControlEvents:UIControlEventValueChanged];[self.collectionView addSubview:refreshControl];self.collectionView.alwaysBounceVertical = YES;


Attributes/Scroll View/Bounce Vertically in Storyboard/Xib

enter image description here


Larry's answer in swift:

    let refreshControl = UIRefreshControl()    refreshControl.tintColor = UIColor.blueColor()    refreshControl.addTarget(self, action: "refresh", forControlEvents: .ValueChanged)    collectionView.addSubview(refreshControl)    collectionView.alwaysBounceVertical = true

Swift 3:

    let refreshControl = UIRefreshControl()    refreshControl.tintColor = .blue    refreshControl.addTarget(self, action: #selector(refresh), for: .valueChanged)    collectionView.addSubview(refreshControl)    collectionView.alwaysBounceVertical = true