I am implementing a feature on the collectionView where user scrolls the collectionView at the bottom (20 items) and it requests another set of data (20 more items) from the
Swift 4.2
When you call reloadData() inside CollectionView delegate method you will see blank cells. You need call it like this.
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
if indexPath.row == collectionView.numberOfItems(inSection: indexPath.section) - 1 {
updateNextSet()
}
}
func updateNextSet(){
print("On Completetion")
//requests another set of data (20 more items) from the server.
DispatchQueue.main.async(execute: collectionView.reloadData)
}