{"id":15293592,"url":"https://github.com/mu29/flexiblepageviewcontroller","last_synced_at":"2025-08-18T13:03:30.173Z","repository":{"id":56911416,"uuid":"88233742","full_name":"mu29/FlexiblePageViewController","owner":"mu29","description":"The simplest way to make your view pager paginable","archived":false,"fork":false,"pushed_at":"2017-04-14T06:02:33.000Z","size":574,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T14:07:27.473Z","etag":null,"topics":["infinite-scroll","ios","pageviewcontroller","pagination","swift","swift3"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mu29.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-14T04:46:56.000Z","updated_at":"2024-04-12T07:20:07.000Z","dependencies_parsed_at":"2022-08-21T03:20:09.630Z","dependency_job_id":null,"html_url":"https://github.com/mu29/FlexiblePageViewController","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mu29%2FFlexiblePageViewController","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mu29%2FFlexiblePageViewController/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mu29%2FFlexiblePageViewController/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mu29%2FFlexiblePageViewController/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mu29","download_url":"https://codeload.github.com/mu29/FlexiblePageViewController/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724637,"owners_count":21151561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["infinite-scroll","ios","pageviewcontroller","pagination","swift","swift3"],"created_at":"2024-09-30T16:50:09.144Z","updated_at":"2025-04-13T14:07:31.420Z","avatar_url":"https://github.com/mu29.png","language":"Swift","readme":"# FlexiblePageViewController\n\n[![Version](https://img.shields.io/cocoapods/v/FlexiblePageViewController.svg?style=flat)](http://cocoapods.org/pods/FlexiblePageViewController)\n[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/mu29/FlexiblePageViewController/blob/master/LICENSE)\n[![Platform](https://img.shields.io/cocoapods/p/FlexiblePageViewController.svg?style=flat)](http://cocoapods.org/pods/FlexiblePageViewController)\n[![Swift 3.1](https://img.shields.io/badge/Swift-3.1-orange.svg?style=flat)](https://developer.apple.com/swift/)\n\nUIPageViewController for processing arbitrary data\n\n## Introduction\n\nWe show data imported from a network or database in a table view through pagination(a.k.a infinite scroll).\n`FlexiblePageViewController` is its pager version that extends `UIPageViewController`.\n\n## Installation\n\n`FlexiblePageViewController` is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"FlexiblePageViewController\"\n```\n\n## Description\n\nTo handle arbitrary data, `FlexiblePageViewController` provides `FlexiblePageViewDataSource` and `FlexiblePageViewDelegate` protocols.\n\nIn `FlexiblePageViewDataSource`, you should return the number of data to display and the data at a specific index.\n\n```swift\nfunc numberOfData(in pageView: FlexiblePageViewController) -\u003e Int {\n  return contents.count\n}\n\nfunc flexiblePageView(_ pageView: FlexiblePageViewController, dataAt index: Int) -\u003e Any? {\n  guard contents.indices.contains(index) else { return nil }\n  return contents[index]\n}\n```\n\nIn `FlexiblePageViewDelegate`, you should performs pagination operations.\n\n```swift\nfunc flexiblePageView(_ pageView: FlexiblePageViewController, lastIndex index: Int) {\n  loadData(at: page)\n}\n```\n\nThe view controller acting as the \"page\" to show each item is assigned to the `pageInfo` as a tuple.\n```swift\npageContainer.pageInfo = (storyboard: \"Main\", view: ContentViewController.self)\n```\n\n\n## Usage\n\n`MainViewController` that act as a pager:\n\n```swift\nimport UIKit\nimport FlexiblePageViewController\n\nclass MainViewController: UIViewController {\n\n  @IBOutlet weak var pageLbl: UILabel!\n\n  var pageContainer: FlexiblePageViewController!\n  var contents: [String] = []\n  var page = 0\n  let contentDataSource = ContentDataSource()\n\n  override func viewDidLoad() {\n    super.viewDidLoad()\n    loadData(at: page) {\n      self.setPager()\n    }\n  }\n\n  private func setPager() {\n    pageContainer = FlexiblePageViewController()\n    pageContainer.pageDataSource = self\n    pageContainer.pageDelegate = self\n    pageContainer.numberOfItemsPerPage = 10\n    pageContainer.didPageSelected = didPageSelected\n    pageContainer.pageInfo = (storyboard: \"Main\", view: ContentViewController.self)\n    view.addSubview(pageContainer.view)\n    view.sendSubview(toBack: pageContainer.view)\n  }\n\n  func didPageSelected(index: Int) {\n    pageLbl.text = \"Page \\(index + 1)\"\n  }\n\n  func loadData(at page: Int, onComplete: (() -\u003e Void)? = nil) {\n    contentDataSource.loadData(at: page) {\n      self.contents.append(contentsOf: $0)\n      self.page += 1\n      onComplete?()\n    }\n  }\n\n}\n\nextension MainViewController: FlexiblePageViewDataSource, FlexiblePageViewDelegate {\n\n  func numberOfData(in pageView: FlexiblePageViewController) -\u003e Int {\n    return contents.count\n  }\n\n  func flexiblePageView(_ pageView: FlexiblePageViewController, dataAt index: Int) -\u003e Any? {\n    guard contents.indices.contains(index) else { return nil }\n    return contents[index]\n  }\n\n  func flexiblePageView(_ pageView: FlexiblePageViewController, lastIndex index: Int) {\n    loadData(at: page)\n  }\n\n}\n```\n\n`ContentViewController` to show each data:\n\n```swift\nimport UIKit\nimport FlexiblePageViewController\n\nclass ContentViewController: UIViewController {\n\n  @IBOutlet weak var contentLbl: UILabel!\n\n  var content: String = \"\"\n\n  // Need to receive data from pager\n  override func set(_ extras: [String : Any]) {\n    content = extras[\"data\"] as? String ?? \"\"\n  }\n\n  override func viewWillAppear(_ animated: Bool) {\n    super.viewWillAppear(animated)\n    contentLbl.text = content\n  }\n\n}\n```\n\n\n## Example\n\n\u003cimg src=\"etc/example.gif\" width=\"400\" /\u003e\n\nThe example project loads and displays 10 pages at first.\nAfter passing the page several times, it loads next 10 items. (*pagination*)\n\nSee full example [here](https://github.com/mu29/FlexiblePageViewController/blob/master/Example/FlexiblePageViewController).\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n\n## APIs\n\n- **`.pageDataSource: FlexiblePageViewDataSource?`**\n\n- **`.pageDelegate: FlexiblePageViewDelegate?`**\n\n- **`.numberOfItemsPerPage: Int = 20`**\n\n    Number of items received in a database or network at a time.\n\n- **`.didPageSelected: ((Int) -\u003e Void)?`**\n\n    Function to be executed when the page is selected. Get the current page index as an argument.\n\n- **`.currentIndex: Int = 0`**\n\n    Index of page to be shown\n\n- **`.pageInfo: (storyboard: String, view: UIViewController.Type)`**\n\n    Storyboard name and identifier of the view controller to show each item\n\n\n## Author\n\nInJung Chung / [@mu29](http://mu29.github.io/)\n\n## License\n\n`FlexiblePageViewController` is available under the MIT license. See the [LICENSE](https://github.com/mu29/FlexiblePageViewController/blob/master/LICENSE) file for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmu29%2Fflexiblepageviewcontroller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmu29%2Fflexiblepageviewcontroller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmu29%2Fflexiblepageviewcontroller/lists"}