试试这个
ViewDidLoad
//initialise the refresh controller
refreshControl = [[UIRefreshControl alloc] init];
//set the title for pull request
refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@"pull to Refresh"];
//call he refresh function
[refreshControl addTarget:self action:@selector(refreshMyTableView)
forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;
方法
-(void)refreshMyTableView{
//set the title while refreshing
refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@"Refreshing the TableView"];
//set the date and time of refreshing
NSDateFormatter *formattedDate = [[NSDateFormatter alloc]init];
[formattedDate setDateFormat:@"MMM d, h:mm a"];
NSString *lastupdated = [NSString stringWithFormat:@"Last Updated on %@",[formattedDate stringFromDate:[NSDate date]]];
refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:lastupdated];
//end the refreshing
}
阻止它
[refreshControl endRefreshing];