Another way is to determine if collectionView:cellForItemAtIndexPath last section or last row.
For example, you can have two sections, one section for displaying material, and the other as an indicator, if the current view scrolls to the end:
public func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { if indexPath.section == 2 {
Remember to set and reset to view the state to avoid falling into one state:
public func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { return self.state == .Loading ? 1 : 2 }
And you can also perform detection in other UICollectionViewDelegate methods, for example:
func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) { if indexPath.row == yourData.count{ self.state = .Loading
source share