LoginSignup
24
25

More than 5 years have passed since last update.

下に引っ張って更新する例のヤツの実装方法

Last updated at Posted at 2014-04-21

ずばり、UIRefreshControlを使用して簡単に実装できます。
UITableViewControllerを継承した独自クラスに少し処理を書くだけ。

SampleViewController.m
- (void)viewDidLoad
{
    [super viewDidLoad];
    // UIRefreshControlを生成
    UIRefreshControl *refreshControl = [UIRefreshControl new];
    // 下に引っ張った際に呼び出される処理をactionで指定。
    [refreshControl addTarget:self action:@selector(onRefresh:) forControlEvents:UIControlEventValueChanged];
    // 作成したUIRefreshControlをTableViewControllerに設定
    self.refreshControl = refreshControl;
}

- (void)onRefresh:(id)sender
{
    // 更新開始
    [self.refreshControl beginRefreshing];

    // 更新時に行いたい処理を実装

    // 更新終了
    [self.refreshControl endRefreshing];
}
24
25
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
24
25