UIRefreshControl 是IOS6 引入的新API,苹果估计想取代第三方的pull to refresh。 spa
在iOS6中UITableViewController 已经集成了UIRefreshControl 控件。UIRefreshControl目前只能用于UITableViewController code
初始化: get
self.refreshControl = [[UIRefreshControl alloc]init]; // self.refreshControl.tintColor = [UIColor blueColor]; self.refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@"下拉刷新"]; [self.refreshControl addTarget:self action:@selector(handleData) forControlEvents:UIControlEventValueChanged];
刷新数据: it
- (void) handleData { NSLog(@"refreshed"); [self.refreshControl endRefreshing]; self.refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@"下拉刷新"]; self.count++; [self.tableView reloadData]; }