UIRefreshControl * rc = [[UIRefreshControl alloc] init];//创建刷新控件对象
rc.attributedTitle = [[NSAttributedString alloc] initWithString:@"下拉刷新"];//设置初始化title
[rc addTarget:self action:@selector(refreshTableView) forControlEvents:UIControlEventValueChanged];//添加事件
self.refreshControl = rc;
}
- (void)refreshTableView
{
if (self.refreshControl.refreshing) {//返回值为bool 如果刷新为真
self.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"加载中..."];
NSDate * date = [[NSDate alloc] init];
[self performSelector:@selector(callBackMethod:) withObject:date afterDelay:3];//调用刷新方法 设置刷新时间为3秒
}
}
- (void)callBackMethod:(id)obj
{
[self.refreshControl endRefreshing];//停止刷新
self.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"下拉刷新"];
tableView刷新
最新推荐文章于 2023-04-24 20:13:24 发布