Latest 0.1.0
Homepage https://github.com/salmaanahmed/PaginatedTableView
License MIT
Platforms ios 10.0
Frameworks UIKit
Authors

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. :+1:
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 :heart:
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, [email protected]

License

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

Latest podspec

{
    "name": "PaginatedTableView",
    "version": "0.1.0",
    "summary": "Assign this class to your UITableView and it will be equipped with pull to refresh as well as infinite scroll",
    "description": "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 :)",
    "homepage": "https://github.com/salmaanahmed/PaginatedTableView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Salmaan Ahmed": "[email protected]"
    },
    "source": {
        "git": "https://github.com/salmaanahmed/PaginatedTableView.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "PaginatedTableView/Classes/*.swift",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This