I have an Horizontal
UICollectionView
on my app and I want to load more data when the user reaches the end (or nearly to the end) of UICollectionView w
Take one bool variable and one integer variable for page number like this:
var isDataLoading = false
var pageCount:Int = 1 // Pass this page number in your api
in cellForItemAt method add below code:
if !isDataLoading && indexPath.row == videoViewModel.count - 1 {
isDataLoading = true
pageCount += 1
// add you api call code here with pageCount
}
once you get your data from api set isDataLoading bool to false like below:
self.isDataLoading = false