UIRefreshControl iOS 6 xcode

Gareth picture Gareth · Sep 26, 2012 · Viewed 39.2k times · Source

Does anyone have a short example of how to implement the new UIRefreshControl into xcode. I have a UITableViewController which displays Tweets, want to be able to pull down and refresh.

Answer

danqing picture danqing · Sep 26, 2012

You can just set it up in your viewDidLoad, if you have a UITableViewController:

UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refresh)
         forControlEvents:UIControlEventValueChanged]; 
self.refreshControl = refreshControl;

Then you can do your refresh stuff here:

-(void)refresh {
    // do something here to refresh.
}

When you are done with refreshing, call [self.refreshControl endRefreshing]; to stop the refresh control, as pointed out by rjgonzo.