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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…