Skip to content
Assign this class to your UITableView and it will be equipped with pull to refresh as well as infinite scroll along with a callback where you don't have to worry about page number/size stuff. Thats why libraries exist :)
Branch: master
Clone or download
Latest commit 72e0a85 Apr 18, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example Update to swift 5 Apr 17, 2019
PaginatedTableView Update to swift 5 Apr 17, 2019
.gitignore Initial commit Apr 16, 2019
.swift-version Update to swift 5 Apr 17, 2019
.travis.yml Initial commit Apr 16, 2019
LICENSE Initial commit Apr 16, 2019
PaginatedTableView.podspec Update to swift 5 Apr 17, 2019
README.md Update README.md Apr 18, 2019
_Pods.xcodeproj Initial commit Apr 16, 2019
demo.gif Add files via upload Apr 17, 2019

README.md

PaginatedTableView

Swift 5 Version License Platform Country

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Demo



Pagination or Infinite scroll is a very necessary feature in modern apps. This library makes it super easy to implement infinite scroll.
No need to keep the page number or show/hide loader logic within the ViewController, it will stay as clean as you have simple table view. 👍
Guess what, it comes with pull to refresh by default ;)

Usage

Step 1: Assign custom class

  // Assign custom class to table view in storyboard
  @IBOutlet weak var tableView: PaginatedTableView!

Step 2: Remember to assign paginated delegate and data source ONLY, DO NOT assign tableViewDelegate or tableViewDataSource

  // Add paginated delegates only
  tableView.paginatedDelegate = self
  tableView.paginatedDataSource = self

Step 3: On ViewDidLoad call the load method with refresh true optional parameter

  tableView.loadData(refresh: true)

Step 4: Implement stub and call api

    func loadMore(_ pageNumber: Int, _ pageSize: Int, onSuccess: ((Bool) -> Void)?, onError: ((Error) -> Void)?) {
        // Call your api here
        // Send true in onSuccess in case new data exists, sending false will disable pagination
        
        // If page number is first, reset the list
        if pageNumber == 1 { self.list = [Model]() }
        
        // else append the data to list
        self.list.append(apiResponseList)
        
        // If Api responds with error
        onError?(apiError)        

        // Else end success with flag true if more data available
        let moreDataAvailable = !apiResponseList.isEmpty
        onSuccess?(moreDataAvailable)
    }

Step 5: Enjoy
Yeah! Thats all. You now have paginated table view with infinite scroll along with pull to refresh ❤️
Simple, isnt it?

Installation

PaginatedTableView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'PaginatedTableView'

Author

Salmaan Ahmed, salmaan.ahmed@hotmail.com

License

PaginatedTableView is available under the MIT license. See the LICENSE file for more info.

You can’t perform that action at this time.