LoginSignup
20
24

More than 5 years have passed since last update.

UITableViewで引っ張って更新+無限スクロールできるライブラリを公開しました。

Posted at

About

記事の一覧表示などで無限スクロール(InfiniteScroll)する際や引っ張って更新(PullToRefresh)する際に簡単にできるライブラリが見つからなかったので、Carthageでのライブラリ公開の勉強を兼ねて作ってみました。
当記事に使い方を書いていますが、サンプルコードはgithubに記載しています。

PullAndInfiniteTableView

DemoGif

Installation

Carthageを使ってインストールできます。
github "roana0229/PullAndInfiniteTableView" >= 1.0

Usage

1.継承するクラスをUITableViewからPullAndInfiniteTableViewに変更

2.下記のように、それぞれプロパティの変更とアクション時に実行したい処理を追加

tableView.showPullToRefresh = true
tableView.addPullToRefreshHandler({ [weak self] in ~ })
tableView.showInfiniteScroll = true
tableView.addInfiniteScrollHandler({ [weak self] in ~ })

3.APIを叩いてデータを取得するなど、データ更新処理が終わった時に下記のメソッドを呼ぶ

tableView.refresh(state: RefreshState)
20
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
24