Last active
January 10, 2017 06:16
-
-
Save maheshgiri/3e6740a952d540e97e89d7b264a0aead to your computer and use it in GitHub Desktop.
Pagination in IOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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