Skip to content

Instantly share code, notes, and snippets.

@maheshgiri
Last active January 10, 2017 06:16
Show Gist options
  • Save maheshgiri/3e6740a952d540e97e89d7b264a0aead to your computer and use it in GitHub Desktop.
Save maheshgiri/3e6740a952d540e97e89d7b264a0aead to your computer and use it in GitHub Desktop.
Pagination in IOS
add ```UIScrollViewDelegate``` in tableview/collectionview
``` var isDataLoading:Bool=false
var pageNo:Int=1
var limit:Int=0
var offset:Int=0
var connectionCount:Int=0```
```override method func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
if scrollView == collectionView{
if ((collectionView.contentOffset.y + collectionView.frame.size.height) >= collectionView.contentSize.height)
{
if !isDataLoading{
DispatchQueue.main.async {
self.activityIndicator.startAnimating()
}
isDataLoading = true
self.pageNo=self.pageNo+1
self.limit=self.limit+20
self.offset=self.limit * self.pageNo
loadCallLogs(offset: self.offset, limit: self.limit)
}
}
}
}```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment