UIRefreshControl 是IOS6 引入的新API,苹果估计想取代第三方的pull to refresh。
在iOS6中UITableViewController 已经集成了UIRefreshControl 控件。UIRefreshControl目前只能用于UITableViewController
初始化:
1 | self.refreshControl = [[UIRefreshControl alloc]init]; |
3 | self.refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@ "下拉刷新" ]; |
4 | [self.refreshControl addTarget:self action:@selector(handleData) forControlEvents:UIControlEventValueChanged]; |
刷新数据:
4 | [self.refreshControl endRefreshing]; |
5 | self.refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@ "下拉刷新" ]; |
8 | [self.tableView reloadData]; |